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

NotImplementedError with nest_asyncio on Unix #108

Open
pkgw opened this issue Dec 15, 2023 · 0 comments
Open

NotImplementedError with nest_asyncio on Unix #108

pkgw opened this issue Dec 15, 2023 · 0 comments

Comments

@pkgw
Copy link

pkgw commented Dec 15, 2023

I'm experiencing a crash when I try to combine qasync with nest_asyncio on a Linux machine (running Python 3.9, Qt 5.15, but the problem doesn't seem to depend on those factors).

Here's a reproduction case:

#! /usr/bin/env python3

import asyncio
import nest_asyncio
from qasync import QEventLoop, QApplication

async def inner():
    print("inner before")
    await asyncio.sleep(1)
    print("inner after")

async def main():
    nest_asyncio.apply()
    loop = asyncio.get_event_loop()
    loop.run_until_complete(inner())
    await asyncio.sleep(1)  # justify this function's async-ness

app = QApplication([])
event_loop = QEventLoop(app)
asyncio.set_event_loop(event_loop)

with event_loop:
    event_loop.run_until_complete(main())

This leads to:

Traceback (most recent call last):
  File "./crashdemo.py", line 32, in <module>
    test()
  File "./crashdemo.py", line 26, in test
    loop.run_until_complete(inner())
  File "/a/lib/python3.9/site-packages/nest_asyncio.py", line 93, in run_until_complete
    self._run_once()
  File "/a/lib/python3.9/site-packages/nest_asyncio.py", line 116, in _run_once
    event_list = self._selector.select(timeout)
  File "/a/lib/python3.9/site-packages/qasync/_unix.py", line 53, in select
    raise NotImplementedError

Am I doing something wrong here? It's been a while since I've worked on the code that uses this functionality, but I think that this worked in my application when I first wrote the code, which was about 2 years ago.

addendum: I did just notice that the nest-asyncio README says that "[event] loops from other projects, such as uvloop or quamash, generally can’t be patched.", so maybe this is something that shouldn't be expected to work. I don't know enough about the codebase to know whether the above error is indicative of this, or something that can potentially be fixed.

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

No branches or pull requests

1 participant