From 1220b7c30944a671d321223166cc7164c030ee0a Mon Sep 17 00:00:00 2001 From: David Skoog Date: Tue, 16 Dec 2025 13:18:44 -0500 Subject: [PATCH 1/4] Remove IOLoop.clear_instance from utils_test.py https://www.tornadoweb.org/en/stable/ioloop.html#tornado.ioloop.IOLoop.clear_instance clear_instance is now an alias for clear_current and has been deprecated since Tornado 5.0 --- streamz/utils_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/streamz/utils_test.py b/streamz/utils_test.py index 9dbc1749..03dc4920 100644 --- a/streamz/utils_test.py +++ b/streamz/utils_test.py @@ -43,7 +43,6 @@ def double(x): @contextmanager def pristine_loop(): - IOLoop.clear_instance() IOLoop.clear_current() loop = IOLoop() loop.make_current() @@ -51,7 +50,6 @@ def pristine_loop(): yield loop finally: loop.close(all_fds=True) - IOLoop.clear_instance() IOLoop.clear_current() From feb649d8dbe9f366d611ac6acd50c71a7bc34839 Mon Sep 17 00:00:00 2001 From: David Skoog Date: Tue, 16 Dec 2025 13:35:06 -0500 Subject: [PATCH 2/4] Remove explicit IOLoop.make_current in utils_test Tornado 4.2 add an optional keyword to IOLoop(make_current=False) Tornado 6.3 changes that to make_current=True so the default behavior is to install the loop as the current thread's loop. --- streamz/utils_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/streamz/utils_test.py b/streamz/utils_test.py index 03dc4920..b3602257 100644 --- a/streamz/utils_test.py +++ b/streamz/utils_test.py @@ -45,7 +45,6 @@ def double(x): def pristine_loop(): IOLoop.clear_current() loop = IOLoop() - loop.make_current() try: yield loop finally: From 0b0f41a9599554dd9a57367f97d50b5dd32af163 Mon Sep 17 00:00:00 2001 From: David Skoog Date: Tue, 16 Dec 2025 13:48:05 -0500 Subject: [PATCH 3/4] Remove explicit use of IOLoop.clear_current() IOLoop.clear_current is deprecated since Tornado 6.2 If proactive manipulation of the running loop is required, the API docs say to use asyncio.set_event_loop() --- streamz/utils_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/streamz/utils_test.py b/streamz/utils_test.py index b3602257..694a23b4 100644 --- a/streamz/utils_test.py +++ b/streamz/utils_test.py @@ -43,13 +43,11 @@ def double(x): @contextmanager def pristine_loop(): - IOLoop.clear_current() loop = IOLoop() try: yield loop finally: loop.close(all_fds=True) - IOLoop.clear_current() def gen_test(timeout=10): From 0783d91d3aa2dcf4f574da36b74e877b54c60858 Mon Sep 17 00:00:00 2001 From: David Skoog Date: Tue, 16 Dec 2025 15:05:55 -0500 Subject: [PATCH 4/4] Fix several "no active event loop" warnings * Go back to IOLoop(make_current=False) to avoid proactively starting the loop when the underlying asyncio system is not ready. * Turn streamz/tests/test_core.py::test_timed_window_timedelta into a coroutine as the underlying event loop needs to be live. --- streamz/core.py | 2 +- streamz/tests/test_core.py | 3 ++- streamz/utils_test.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/streamz/core.py b/streamz/core.py index 02d77dfc..ae7a27f9 100644 --- a/streamz/core.py +++ b/streamz/core.py @@ -51,7 +51,7 @@ def get_io_loop(asynchronous=None): return client.loop if not _io_loops: - loop = IOLoop() + loop = IOLoop(make_current=False) thread = threading.Thread(target=loop.start) thread.daemon = True thread.start() diff --git a/streamz/tests/test_core.py b/streamz/tests/test_core.py index b1c51280..96ab9a24 100644 --- a/streamz/tests/test_core.py +++ b/streamz/tests/test_core.py @@ -444,7 +444,8 @@ def test_timed_window_metadata(): ] -def test_timed_window_timedelta(clean): # noqa: F811 +@pytest.mark.asyncio +async def test_timed_window_timedelta(clean): # noqa: F811 pytest.importorskip('pandas') source = Stream(asynchronous=True) a = source.timed_window('10ms') diff --git a/streamz/utils_test.py b/streamz/utils_test.py index 694a23b4..6ff76ad7 100644 --- a/streamz/utils_test.py +++ b/streamz/utils_test.py @@ -43,7 +43,7 @@ def double(x): @contextmanager def pristine_loop(): - loop = IOLoop() + loop = IOLoop(make_current=False) try: yield loop finally: