Issue 926910: Overenthusiastic check in Swap? (original) (raw)
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/40111
classification
Title: | Overenthusiastic check in Swap? | |
---|---|---|
Type: | Stage: | |
Components: | Interpreter Core | Versions: |
process
Status: | closed | Resolution: | wont fix |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | mhammond | Nosy List: | benson_basis, mhammond, rhettinger |
Priority: | normal | Keywords: |
Created on 2004-03-31 19:34 by benson_basis, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (5) | ||
---|---|---|
msg20400 - (view) | Author: benson margulies (benson_basis) | Date: 2004-03-31 19:34 |
When Py_DEBUG is turned on, PyThreadState_Swap calls in a fatal error if the two different thread states are ever used for a thread. I submit that this is not a good check. The documentation encourages us to write code that creates and destroys thread states as C threads come and go. Why can't a single C thread make a thread state, release it, and then make another one later? One particular usage pattern: We have an API that initializes embedded python. Then we have another API where the callers are allowed to be in any C thread. The second API has no easy way to tell if a thread used for it happens to be the same thread that made the initialization call. As the code is written now, any code running on the 'main thread' is required to fish out the build-in main-thread thread state. | ||
msg20401 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2004-06-07 05:15 |
Logged In: YES user_id=80475 Mark, I believe this is your code. | ||
msg20402 - (view) | Author: Mark Hammond (mhammond) * ![]() |
Date: 2004-06-07 07:22 |
Logged In: YES user_id=14198 That check should not fail if you use the PyGILState APIs - it manages all of this for you. The PyGILState functions were added to handle exactly what you describe as your use case - is there any reason you can't use them? | ||
msg20403 - (view) | Author: benson margulies (benson_basis) | Date: 2004-06-07 14:20 |
Logged In: YES user_id=876734 Somehow, the path I took through the documentation failed to rub my nose in this. It would be good if the language from the original PEP was applied to the APIs that I coded to to warn people to use these other APIs instead. | ||
msg20404 - (view) | Author: Mark Hammond (mhammond) * ![]() |
Date: 2007-08-21 01:18 |
The docs probably could be improved, but for now, this bug as reported is not going to be fixed. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:03 | admin | set | github: 40111 |
2004-03-31 19:34:01 | benson_basis | create |