-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
testsUnit tests and/or continuous integrationUnit tests and/or continuous integration
Description
I'm seeing this flakey test failing on python 3.7 envs. For instance https://github.com/dask/dask/runs/3115042732
2021-07-20T15:02:39.1543087Z @pytest.mark.flaky(reruns=10, reruns_delay=5)
2021-07-20T15:02:39.1543896Z def test_interrupt():
2021-07-20T15:02:39.1544725Z # Windows implements `queue.get` using polling,
2021-07-20T15:02:39.1545699Z # which means we can set an exception to interrupt the call to `get`.
2021-07-20T15:02:39.1546983Z # Python 3 on other platforms requires sending SIGINT to the main thread.
2021-07-20T15:02:39.1547882Z if os.name == "nt":
2021-07-20T15:02:39.1548599Z from _thread import interrupt_main
2021-07-20T15:02:39.1549295Z else:
2021-07-20T15:02:39.1549993Z main_thread = threading.get_ident()
2021-07-20T15:02:39.1550680Z
2021-07-20T15:02:39.1551284Z def interrupt_main():
2021-07-20T15:02:39.1552166Z signal.pthread_kill(main_thread, signal.SIGINT)
2021-07-20T15:02:39.1552932Z
2021-07-20T15:02:39.1553502Z def long_task():
2021-07-20T15:02:39.1554121Z sleep(5)
2021-07-20T15:02:39.1554671Z
2021-07-20T15:02:39.1555323Z dsk = {("x", i): (long_task,) for i in range(20)}
2021-07-20T15:02:39.1556070Z dsk["x"] = (len, list(dsk.keys()))
2021-07-20T15:02:39.1556702Z try:
2021-07-20T15:02:39.1557500Z interrupter = threading.Timer(0.5, interrupt_main)
2021-07-20T15:02:39.1558385Z interrupter.start()
2021-07-20T15:02:39.1559863Z start = time()
2021-07-20T15:02:39.1560469Z get(dsk, "x")
2021-07-20T15:02:39.1561132Z except KeyboardInterrupt:
2021-07-20T15:02:39.1561758Z pass
2021-07-20T15:02:39.1562322Z except Exception:
2021-07-20T15:02:39.1563014Z assert False, "Failed to interrupt"
2021-07-20T15:02:39.1563658Z stop = time()
2021-07-20T15:02:39.1564478Z if stop - start > 4:
2021-07-20T15:02:39.1565147Z > assert False, "Failed to interrupt"
2021-07-20T15:02:39.1565932Z E AssertionError: Failed to interrupt
2021-07-20T15:02:39.1566609Z E assert False
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
testsUnit tests and/or continuous integrationUnit tests and/or continuous integration