-
Notifications
You must be signed in to change notification settings - Fork 57
Update timeout example in README.rst #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Corrects the error being thrown in the timeout example and makes it more meaningful by adding sleep to simulate tasks and printing results from processes that finish.
|
|
||
| def function(foo, bar=0): | ||
| time.sleep(foo) # simulate a task | ||
| return foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bar is not used anymore, the original README was returning foo + bar.
|
|
||
| with ProcessPool(max_workers=5, max_tasks=10) as pool: | ||
| for index in range(0, 10): | ||
| future = pool.schedule(function, [index], {'bar':1}, timeout=TIMEOUT_SECONDS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use KW arguments properly to better indicate how to call this function.
future = pool.schedule(function, args=[index], kwargs={'bar':1}, timeout=TIMEOUT_SECONDS)
noxdafox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
I did not understand what was the issue with the TimeoutError handling.
Could you please make the fixes as requested in the comments?
a877e32 to
dcdd92e
Compare
Corrects the error being thrown in the timeout example in README and makes it more meaningful by adding sleep to simulate tasks and printing results from processes that finish.