This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jiangwanwei
Recipients jiangwanwei
Date 2017-03-06.11:23:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
when I use as_completed function to wait my futures, if I sleep more than timeout seconds in each iteration , I found that futures has been set result, but raise TimeoutError. as my test example code shows:

from concurrent import futures
from multiprocessing import current_process
import time

def run(count):
    cp = current_process()
    print(, 'begin', count, 'at', time.time())
    print(, 'end', count, 'at', time.time())
    return count

if __name__ == '__main__':
    ppe = futures.ProcessPoolExecutor(max_workers=4)
    cp = current_process()

    fs = [ppe.submit(run, i) for i in range(4)]

    print('begin receive at', time.time())
    for f in futures.as_completed(fs, timeout=5):
        print(, 'receive', f.result(), 'at', time.time())
        print(, 'receive', [f.result() for f in fs], 'at', time.time())
    print('end receive at', time.time())

run above-mentioned example code, it will output :
begin receive at 1488799136.471536
Process-1 begin 0 at 1488799136.472969
Process-1 end 0 at 1488799136.473114
Process-3 begin 1 at 1488799136.473741
Process-2 begin 2 at 1488799136.474226
Process-4 begin 3 at 1488799136.474561
Process-3 end 1 at 1488799137.474495
Process-2 end 2 at 1488799138.475289
Process-4 end 3 at 1488799139.475696
MainProcess receive 0 at 1488799141.478663
MainProcess receive [0, 1, 2, 3] at 1488799141.478787
Traceback (most recent call last):
  File "", line 23, in <module>
    for f in futures.as_completed(fs, timeout=5):
  File "/Users/jiangwanwei/anaconda3/lib/python3.5/concurrent/futures/", line 213, in as_completed
    len(pending), len(fs)))
concurrent.futures._base.TimeoutError: 3 (of 4) futures unfinished
Date User Action Args
2017-03-06 11:23:33jiangwanweisetrecipients: + jiangwanwei
2017-03-06 11:23:33jiangwanweisetmessageid: <>
2017-03-06 11:23:33jiangwanweilinkissue29733 messages
2017-03-06 11:23:33jiangwanweicreate