[issue41694] python3 futures.as_completed timeout broken if future contains undefined reference

Dallas Marlow report at bugs.python.org
Wed Sep 2 14:13:50 EDT 2020


Dallas Marlow <dallasmarlow at gmail.com> added the comment:

I apologize for all the messages, but the more I look into this issue the stranger it seems. The following code does the following:

- print the time
- execute 3 futures (2 w/ 30s sleeps)
- call as_completed
- catch the timeout exception
- print the time again
- then raise the timeout exception, but only after all futures complete.

the second time print executes after the as_completed timeout duration, but the exception was only raised after all futures completed. the exception message incorrectly states that it left 2/3 futures unfinished.

#########################

import concurrent.futures
import time

with concurrent.futures.ThreadPoolExecutor() as ex:
	print(time.time())
	futures = [
		ex.submit(time.sleep, 30),
		ex.submit(time.sleep, 30),
		ex.submit(print, 'test'),
	]
	try:
		for future in concurrent.futures.as_completed(
			futures, timeout=1):
			_ = future.result()
	except Exception as e:
		print(time.time())
		raise e

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41694>
_______________________________________


More information about the Python-bugs-list mailing list