[issue29102] Add an id field to PyInterpreterState.

Steve Dower report at bugs.python.org
Thu Dec 29 12:47:54 EST 2016


Steve Dower added the comment:

That's an issue with TLS initialisation, not thread IDs. It's easily solved by defining an "uninitialized" value (e.g. 0) and an "invalid" value (e.g. -1).

Interpreter states are in a linked list, so you can traverse the list to find one by ID.

WRT weakrefs, we can't use them directly, but I suspect the higher-level API will need it. Possibly adding a callback on finalisation would fill both needs, but I like having a reliable ID - otherwise we'll probably end up with multiple different IDs managed indirectly via callbacks. (Perhaps a single callback for when any interpreter is finalized that passes the ID through? That should work well, since the ID is designed to outlive the interpreter itself, so it can be an asynchronous notification.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29102>
_______________________________________


More information about the Python-bugs-list mailing list