Add pytest fixture to clean up the IO loop
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- testing-qa
Research direction
Start by locating the streamz unit tests and the existing pristine_loop fixture. Compare that fixture with the proposed loop_cleaner cleanup, then run the affected tests to reproduce the running-event-loop error. Done means the tests leave no running or open global asyncio event loop and pass reliably with the jupyter_core change described.
Written by the indexing model from the issue text.
Description
I recently came across this error in my unit tests:
RuntimeError: This event loop is already running
The error doesn't come from streamz, it's from jupyter_core, in this recent change.
But it is triggered because my streamz tests don't clean up properly after them selves.
They leave the global async event loop, asyncio.get_event_loop(), in a running state.
To fix it I had to add this fixture to my unit tests:
@pytest.fixture(autouse=True)
def loop_cleaner():
yield None
close_io_loop()
def close_io_loop():
IOLoop().current().stop()
IOLoop().current().close()
assert not asyncio.get_event_loop().is_running()
asyncio.get_event_loop().close()
assert asyncio.get_event_loop().is_closed()
asyncio.set_event_loop(None)
It's a bit similar to the existing pristine_loop, but doesn't exactly do the same thing (afaict).
I hope this can help any one having similar issues.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 149
- Avg merge
- 17h 39m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-streamz/streamz
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
python-streamz/streamz#481 · 4 comments ·
-
Combining the streamz.Stream.filenames() and streamz.Stream.from_textfile() using dask scatter? Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
python-streamz/streamz#480 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
python-streamz/streamz#479 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
python-streamz/streamz#478 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 10/100
python-streamz/streamz#476 · 17 comments · 2 reactions ·
All issues in python-streamz/streamz
Similar issues
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openml/openml-python#1749 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sipyourdrink-ltd/bernstein#6191 ·