Skip to content
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

asyncio.exceptions.CancelledError with simple async code #167

Open
Almenon opened this issue May 3, 2021 · 1 comment
Open

asyncio.exceptions.CancelledError with simple async code #167

Almenon opened this issue May 3, 2021 · 1 comment

Comments

@Almenon
Copy link
Owner

Almenon commented May 3, 2021

The simplified version of the hello world example from https://docs.python.org/3/library/asyncio.html:

import asyncio


async def main():
    pass

asyncio.run(main())

results in a error being logged to stderr:

Error on reading from the event loop self pipe
loop: <ProactorEventLoop running=True closed=False debug=False>
Traceback (most recent call last):
  File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 768, in _loop_self_reading
    f.result()  # may raise
asyncio.exceptions.CancelledError
Error on reading from the event loop self pipe
loop: <ProactorEventLoop running=True closed=False debug=False>
Traceback (most recent call last):
  File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 768, in _loop_self_reading
    f.result()  # may raise
asyncio.exceptions.CancelledError

(Note that it logs to stderr instead of throwing an exception because that's the default behavior of event loops - see default_exception_handler of C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py.)

Exepcted results:
No error logged, same as when program is run via python directly

Actual Results:
Error logged.

OS: Windows 10
Python: v3.9

Full error: (logged if you specify debug=True)

``` Error on reading from the event loop self pipe handle_traceback: Handle created at (most recent call last): File "c:\Users\almenon\.vscode\extensions\almenon.arepl-2.0.2\node_modules\arepl-backend\python\arepl_python_evaluator.py", line 330, in main(input()) File "c:\Users\almenon\.vscode\extensions\almenon.arepl-2.0.2\node_modules\arepl-backend\python\arepl_python_evaluator.py", line 298, in main return_info = exec_input(execArgs) File "c:\Users\almenon\.vscode\extensions\almenon.arepl-2.0.2\node_modules\arepl-backend\python\arepl_python_evaluator.py", line 242, in exec_input run_context.run(exec, exec_args.evalCode, eval_locals) File "", line 7, in File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 629, in run_until_complete self.run_forever() File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 320, in run_forever self._self_reading_future.cancel() File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 80, in cancel return super().cancel(msg=msg) loop: Traceback (most recent call last): File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 768, in _loop_self_reading f.result() # may raise asyncio.exceptions.CancelledError Error on reading from the event loop self pipe handle_traceback: Handle created at (most recent call last): File "c:\Users\almenon\.vscode\extensions\almenon.arepl-2.0.2\node_modules\arepl-backend\python\arepl_python_evaluator.py", line 330, in main(input()) File "c:\Users\almenon\.vscode\extensions\almenon.arepl-2.0.2\node_modules\arepl-backend\python\arepl_python_evaluator.py", line 298, in main return_info = exec_input(execArgs) File "c:\Users\almenon\.vscode\extensions\almenon.arepl-2.0.2\node_modules\arepl-backend\python\arepl_python_evaluator.py", line 242, in exec_input run_context.run(exec, exec_args.evalCode, eval_locals) File "", line 7, in File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 48, in run loop.run_until_complete(loop.shutdown_asyncgens()) File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 629, in run_until_complete self.run_forever() File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 320, in run_forever self._self_reading_future.cancel() File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 80, in cancel return super().cancel(msg=msg) loop: Traceback (most recent call last): File "C:\Users\almenon\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 768, in _loop_self_reading f.result() # may raise asyncio.exceptions.CancelledError ```
@Almenon
Copy link
Owner Author

Almenon commented May 3, 2021

So basically the event loop is getting cancelled for some reason... but I'm not sure why.

I tried doing a simple exec but that didn't get the error. I should try running arepl directly, mocking the JSON input, and changing code around untill I figure out what causes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant