File tree Expand file tree Collapse file tree 2 files changed +2
-3
lines changed
Expand file tree Collapse file tree 2 files changed +2
-3
lines changed Original file line number Diff line number Diff line change 77# custom function to be executed in a worker thread
88def task (number , value ):
99 # report a message
10- print (f'Task generated { value } ' )
10+ print (f'Task received { value } ' )
1111 # block for a moment to simulate work
1212 sleep (value )
1313 # return a new value
Original file line number Diff line number Diff line change 22# example of checking the status of an asynchronous task
33from time import sleep
44from concurrent .futures import ThreadPoolExecutor
5- from concurrent .futures import wait
65
76# task function executed in a worker thread
87def work ():
@@ -20,7 +19,7 @@ def work():
2019 done = future .done ()
2120 print (f'Future running={ running } , done={ done } ' )
2221 # wait for the task to complete
23- wait ([ future ] )
22+ future . result ( )
2423 # confirm that the task is done
2524 running = future .running ()
2625 done = future .done ()
You can’t perform that action at this time.
0 commit comments