-
Notifications
You must be signed in to change notification settings - Fork 159
Running concurrent event loops #383
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
Comments
I'm not aware of a better solution. asyncio is limited to at most one event loop per thread. This is by design. If you need concurrent event loops, you need to resort to multiple processes or multiple threads like you did. You might be able to work around that using https://github.com/erdewit/nest_asyncio, but it should only be used for tests. Does this answer you question? |
thank you @pytest.mark.run_in_threaded_loop But i don’t know if it’s a very needed feature |
It's worth investigating if this functionality can be added to the new asyncio_event_loop mark (see #620). |
Another use case I ran into was using |
Yes, Pytest-asyncio currently assumes that it is the only library managing the asyncio event loop. @wRAR Can you share more details about your use case? Why is it necessary to use pytest-twisted and pytest-asyncio together? |
@seifertm most of the details are in pytest-dev/pytest-twisted#188, basically I need to run Twisted-based code that uses the asyncio reactor in test functions (which, to my knowledge, requires running the reactor in a correct way, so I either need pytest-twisted or need to run it myself somehow, and in any case I will have a long-running asyncio event loop managed by the reactor) but want to use some asyncio-based fixtures, in my use case they are aiohttp ones, using Hope this is clear. |
To test the basic usage of websockets, I want to start a server and test the return string from client, I think server and client should be in separate thread.
The below code passed, but I just want to know if there's a proper/generalized way to do it?
The text was updated successfully, but these errors were encountered: