-
-
Notifications
You must be signed in to change notification settings - Fork 537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support to run on top of trio #725
Comments
Not directly, but the trio-asyncio compatibility layer looks promising. I can get import trio_asyncio
import chess.engine
async def main():
transport, engine = await trio_asyncio.aio_as_trio(chess.engine.popen_uci)("/usr/bin/stockfish")
result = await trio_asyncio.aio_as_trio(engine.play)(chess.Board(), chess.engine.Limit(time=0.1))
print(result)
await trio_asyncio.aio_as_trio(engine.quit)()
trio_asyncio.run(main) to run with a small patch: diff --git a/chess/engine.py b/chess/engine.py
index 2a02c7c..d970e9d 100644
--- a/chess/engine.py
+++ b/chess/engine.py
@@ -936,7 +936,7 @@ class Protocol(asyncio.SubprocessProtocol, metaclass=abc.ABCMeta):
"""Future: Exit code of the process."""
def __init__(self: ProtocolT) -> None:
- self.loop = asyncio.get_running_loop()
+ self.loop = asyncio.get_event_loop()
self.transport: Optional[asyncio.SubprocessTransport] = None
self.buffer = {
@@ -1195,7 +1195,7 @@ class Protocol(asyncio.SubprocessProtocol, metaclass=abc.ABCMeta):
popen_args["preexec_fn"] = os.setpgrp
popen_args.update(kwargs)
- return await asyncio.get_running_loop().subprocess_exec(cls, *command, **popen_args) # type: ignore
+ return await asyncio.get_event_loop().subprocess_exec(cls, *command, **popen_args) # type: ignore
class CommandState(enum.Enum): Somehow it does not appear to support |
|
Sorry, but I still have errors running your snippet: I'm using python 3.8, trio 0.17.0, trio-asyncio 0.11.0 and chess 1.3.3 using
|
Sorry to make you reopen the bug, I think the underlying cause is python-trio/trio-asyncio#97 (and the fact that I'm using a windows machine) |
Maybe wait until chess v1.3.4? Because chess v1.3.3 does not include the trio-asyncio fix that Niklas has commited to the master branch. Just my 2 cents. But if you have manually edited your chess v1.3.3 codebase with the fix that Niklas has provided, then we have an unsolved issue. |
@PedanticHacker I am using master:
FWIW the demo code seems to work on WSL |
This is clearly out of my expertise. Just wait some time, Niklas will respond. |
@PedanticHacker Have you received my email (end of December)? I was asking you to hold back on communication when you are unsure about an issue, to avoid needless notifications. Final warning. |
Alright, trio-asyncio v0.12.0 (just released) includes the proper fix, so I reverted the workaround. Subprocess support is still missing on Windows, but there's not much that could be done in python-chess, so closing. |
the engine docs says
is there some way to run
python-chess
on top of trio event loop?The text was updated successfully, but these errors were encountered: