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

Seems like worker threads are occasionally cleaned up before they're started #1

Open
initialed85 opened this issue Mar 16, 2018 · 1 comment

Comments

@initialed85
Copy link
Contributor

If there are more calls than workers submitted in the moment before the cleanup runs, it seems that the freshly created threads (to meet the increase in demand) are immediately cleaned up.

This shouldn't happen as I'm checking for thread.ident (to show that thread was ever started) as well as not thread.isAlive() (to show that thread is now stopped).

Need to dig into it.

@lukecwik
Copy link

lukecwik commented Sep 4, 2019

Since isAlive relies on __started being set, there is a race where ident can be set and isAlive returns false during the new threads bootstrapping process. This means that checking ident and then !isAlive can mark the worker as dead during the bootstrap process.

This seems to be an issue from Py 2.7:
https://hg.python.org/cpython/file/2.7/Lib/threading.py#l785
and still is an issue in the current version:
https://github.com/python/cpython/blob/60bd1f88f21073965a444c8b39c4202d015da5d6/Lib/threading.py#L929

Was there a point in time where the new worker was being added to the list of known workers before start() was being invoked?

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

No branches or pull requests

2 participants