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

Test fixtures gen_cluster gen_test are using asyncio.run #6164

Closed
1 of 4 tasks
Tracked by #6049
fjetter opened this issue Apr 20, 2022 · 2 comments
Closed
1 of 4 tasks
Tracked by #6049

Test fixtures gen_cluster gen_test are using asyncio.run #6164

fjetter opened this issue Apr 20, 2022 · 2 comments
Assignees

Comments

@fjetter
Copy link
Member

fjetter commented Apr 20, 2022

@fjetter fjetter changed the title pristine_loop fixture likely needs to be removed. This also affects other fixtures like gen_cluster, gen_test, loop, cleanup, etc. Test fixtures gen_cluster gen_test are using asyncio.run Apr 20, 2022
mrocklin pushed a commit that referenced this issue Apr 21, 2022
when using `asyncio.run` in `gen_test` test that later call `asyncio.get_event_loop()` fail - even before python3.10:


```python
import asyncio

async def amain():
    pass

asyncio.run(amain())
asyncio.get_event_loop()
```

```pytb
Traceback (most recent call last):
  File "foo.py", line 7, in <module>
    asyncio.get_event_loop()
  File "/usr/lib/python3.8/asyncio/events.py", line 639, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'MainThread'.
```

* use `gen_test` for tests that acquire `IOLoop.current()`
* use `get_running_loop()` instead of `get_event_loop()`
* use `asyncio.run()` instead of `asyncio.get_event_loop().run_until_complete()`

See #6164
@graingert
Copy link
Member

  • avoid pristine_loop/loop.start in loop_in_thread
  • clear asyncio loop in clean - rather than using pristine_loop - asyncio.set_event_loop(None)

@graingert
Copy link
Member

Fixed by #6231

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

2 participants