Skip to content

Commit eb7fd15

Browse files
FrancescAltedclaude
andcommitted
Stop the subscriber stand-in idling half a second per test
Each test in this file starts a server and shuts it down, and `shutdown()` waits for `serve_forever`'s poll interval to elapse before the loop notices it was asked to stop. At the default half second, and with 27 tests, that was 13.5 s of a 14.5 s file spent waiting for nothing -- enough to make it the slowest file in the suite, and under `--dist loadfile` the slowest file is the wall clock. A hundredth of a second instead: the file goes from 14.45 s to 0.98 s and out of the top ten, and the whole suite from 26 s to 21 s. Nothing about what is tested changes; the poll interval only decides how often an idle serve loop looks up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 95850a8 commit eb7fd15

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎tests/ndarray/test_c2array_blocks.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ def _serve(tmp_path, data, chunks, blocks, name="ds.b2nd", key=None, **kwargs):
183183
tstore[key] = blosc2.asarray(data, chunks=chunks, blocks=blocks)
184184
server = ThreadingHTTPServer(("127.0.0.1", 0), _Handler)
185185
server.subscriber = _Subscriber(urlpath, key=key, **kwargs)
186-
threading.Thread(target=server.serve_forever, daemon=True).start()
186+
# A short poll interval, because `shutdown()` waits for one to elapse before
187+
# the serve loop notices: at the default 0.5 s that is half a second of doing
188+
# nothing per test, and this file has enough of them for that to be most of
189+
# what it costs
190+
threading.Thread(target=server.serve_forever, kwargs={"poll_interval": 0.01}, daemon=True).start()
187191
urlbase = f"http://127.0.0.1:{server.server_address[1]}/"
188192
path = f"@public/{name}{key or ''}"
189193
array = blosc2.C2Array(path, urlbase=urlbase, auth_token=kwargs.get("cookie"))

0 commit comments

Comments
 (0)