mirror of
https://github.com/python/cpython.git
synced 2025-10-02 13:22:19 +00:00
Delete a broken threading.local example (GH-5870)
This code never did anything correct or useful. The class attribute will never be affected, and the condition will never be true.
(cherry picked from commit 5fb632e831
)
Co-authored-by: Aaron Gallagher <habnabit@users.noreply.github.com>
This commit is contained in:
parent
961774184e
commit
83f4394e4e
1 changed files with 1 additions and 5 deletions
|
@ -56,11 +56,7 @@ You can create custom local objects by subclassing the local class:
|
||||||
|
|
||||||
>>> class MyLocal(local):
|
>>> class MyLocal(local):
|
||||||
... number = 2
|
... number = 2
|
||||||
... initialized = False
|
|
||||||
... def __init__(self, **kw):
|
... def __init__(self, **kw):
|
||||||
... if self.initialized:
|
|
||||||
... raise SystemError('__init__ called too many times')
|
|
||||||
... self.initialized = True
|
|
||||||
... self.__dict__.update(kw)
|
... self.__dict__.update(kw)
|
||||||
... def squared(self):
|
... def squared(self):
|
||||||
... return self.number ** 2
|
... return self.number ** 2
|
||||||
|
@ -97,7 +93,7 @@ As before, we can access the data in a separate thread:
|
||||||
>>> thread.start()
|
>>> thread.start()
|
||||||
>>> thread.join()
|
>>> thread.join()
|
||||||
>>> log
|
>>> log
|
||||||
[[('color', 'red'), ('initialized', True)], 11]
|
[[('color', 'red')], 11]
|
||||||
|
|
||||||
without affecting this thread's data:
|
without affecting this thread's data:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue