Skip to content

Commit a869b28

Browse files
authored
tests: fix StreamWorker test leading to bad Engine state (#502)
An unconfigured StreamWorker does not have streams to register in the engine, so when registered, it stays until it is explicitly aborted. To make that worse, it is using a 'fanout slot' and if the Engine's fanout is too low, it can lead to the engine run loop exiting prematurely. This is not a case handled very well by the Engine. See #497 for more details about the problem. In the meantime, we fix the test to exit with a clean engine state. Fixes #488.
1 parent aae7bc7 commit a869b28

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/StreamWorkerTest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ def test_001_empty(self):
2121
"""test empty StreamWorker"""
2222
# that makes no sense but well...
2323
# handler=None is supported by base Worker class
24-
self.run_worker(StreamWorker(handler=None))
24+
worker = StreamWorker(handler=None)
25+
self.run_worker(worker)
26+
# GH Issue #488:
27+
# An unconfigured engine client does not abort by itself...
28+
worker.abort()
29+
# Check that we are in a clean state now
30+
self.assertEqual(len(task_self()._engine._clients), 0)
2531

2632
def test_002_pipe_readers(self):
2733
"""test StreamWorker bound to several pipe readers"""

0 commit comments

Comments
 (0)