Skip to content

Non-blocking communication with engine #1061

Answered by niklasf
clarke-baxter asked this question in Q&A
Discussion options

You must be logged in to vote

asyncio would have the lowest overhead, but it looks like PySimpleGUI does not provide integration.

The next best thing is to use the blocking chess.engine.SimpleEngine. I found this example for how to deal with blocking operations in PySimpleGUI: https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_Multithreaded_Long_Tasks.py. So window.start_thread() can be used to start work that would otherwise block the main thread, and the thread will be able to send events back to the main thread.

chess.engine.SimpleEngine is thread-safe as long as objects passed to methods are not concurrently modified. So you could create one instance and use it in the background threads.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@clarke-baxter
Comment options

Answer selected by clarke-baxter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants