Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
Bug report
importcontextlibimportfunctoolsimportconcurrent.futuresimportthreadingimportsysdeffn(num,stop_event):ifnum==1:stop_event.wait()return"done 1"ifnum==2:return"done 2"defmain():stop_event=threading.Event()log= []withconcurrent.futures.ThreadPoolExecutor(max_workers=1)aspool:defprint_n_wait(ident):log.append(f"{ident=} started")try:stop_event.wait()finally:log.append(f"{ident=} stopped")fut=pool.submit(print_n_wait,ident="first")try:withcontextlib.closing(pool.map(print_n_wait, ["second","third"],timeout=1))asgen:try:next(gen)exceptconcurrent.futures.TimeoutError:print("timed out")else:raiseRuntimeError("timeout expected")finally:stop_event.set()assertlog== ["ident='first' started","ident='first' stopped"],f"{log=} is wrong"if__name__=="__main__":sys.exit(main())
result in:
timed outTraceback (most recent call last): File "/home/graingert/projects/executor_map.py", line 45, in <module> sys.exit(main()) File "/home/graingert/projects/executor_map.py", line 42, in main assert log == ["ident='first' started", "ident='first' stopped"], f"{log=} is wrong"AssertionError: log=["ident='first' started", "ident='first' stopped", "ident='second' started", "ident='second' stopped"] is wrongYour environment
- CPython versions tested on:
- Operating system and architecture: