A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-July/045794.html below:

[Python-Dev] Version 3 Proposal: thread-local data

[Python-Dev] Version 3 Proposal: thread-local data [Python-Dev] Version 3 Proposal: thread-local dataTim Peters tim.one at comcast.net
Thu Jul 1 00:12:27 EDT 2004
[Jim]
...
>         def __del__(self):
>             key = object.__getattribute__(self, '_local__key')
>             for thread in enumerate():
>                 if key in thread.__dict__:
>                     del thread.__dict__[key]

Note that a __del__ method should never reference a module global
"enumerate" in this case) -- it's all but certain to lead to "iteration over
non-sequence" Mystery Errors at Python shutdown time (due to module globals
getting "None'd out").  The conventional workaround is to give the class an
attribute initialized from the module global; e.g.,

class local(_localbase):
    _enumerate = threading.enumerate

    ...

    def __del__(self):
        ...
        for thread in self._enumerate():

The conventional workaround that doesn't work is to spell that

        for thread in local._enumerate():

instead; it doesn't work because "local" is also a module global.



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4