Skip to content
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

Update timeout example in README.rst #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aleph-ra
Copy link

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.

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
Copy link
Owner

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)
Copy link
Owner

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)

Copy link
Owner

@noxdafox noxdafox left a 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants