Lines Matching +full:import +full:- +full:local
1 """Thread-local objects.
3 (Note that this module provides a Python version of the threading.local
5 faster one available. You should always import the `local` class from
8 Thread-local objects support the management of thread-local data.
9 If you have data that you want to be local to a thread, simply create
10 a thread-local object and use its attributes:
12 >>> mydata = local()
17 You can also access the local-object's dictionary:
26 What's important about thread-local objects is that their data are
27 local to a thread. If we access the data in a different thread:
36 >>> import threading
49 Of course, values you get from a local object, including a __dict__
55 You can create custom local objects by subclassing the local class:
57 >>> class MyLocal(local):
66 called each time the local object is used in a separate thread. This
69 Now if we create a local object:
108 local. They are shared across threads:
110 >>> class MyLocal(local):
131 from weakref import ref
132 from contextlib import contextmanager
134 __all__ = ["local"]
137 # module may also want to use our `local` class, if support for locals
139 # with circular imports. For that reason, we don't import `threading`
142 # for locals in the `thread` module, and there is no circular import problem
147 """A class managing thread-local dicts"""
155 # { id(Thread) -> (ref(Thread), thread-local dict) }
176 # When the thread is deleted, remove the local dict.
179 # as soon as the OS-level thread ends instead.
180 local = wrlocal()
181 if local is not None:
182 dct = local.dicts.pop(idt)
204 class local: class
228 "%r object attribute '__dict__' is read-only"
236 "%r object attribute '__dict__' is read-only"
242 from threading import current_thread, RLock