$26 GRAYBYTE WORDPRESS FILE MANAGER $96

SERVER : in-mum-web1330.main-hosting.eu #1 SMP Mon Feb 10 22:45:17 UTC 2025
SERVER IP : 91.108.106.157 | ADMIN IP 216.73.216.21
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/usr/lib64/python3.8/

HOME
Current File : /usr/lib64/python3.8//_threading_local.py
"""Thread-local objects.

(Note that this module provides a Python version of the threading.local
 class.  Depending on the version of Python you're using, there may be a
 faster one available.  You should always import the `local` class from
 `threading`.)

Thread-local objects support the management of thread-local data.
If you have data that you want to be local to a thread, simply create
a thread-local object and use its attributes:

  >>> mydata = local()
  >>> mydata.number = 42
  >>> mydata.number
  42

You can also access the local-object's dictionary:

  >>> mydata.__dict__
  {'number': 42}
  >>> mydata.__dict__.setdefault('widgets', [])
  []
  >>> mydata.widgets
  []

What's important about thread-local objects is that their data are
local to a thread. If we access the data in a different thread:

  >>> log = []
  >>> def f():
  ...     items = sorted(mydata.__dict__.items())
  ...     log.append(items)
  ...     mydata.number = 11
  ...     log.append(mydata.number)

  >>> import threading
  >>> thread = threading.Thread(target=f)
  >>> thread.start()
  >>> thread.join()
  >>> log
  [[], 11]

we get different data.  Furthermore, changes made in the other thread
don't affect data seen in this thread:

  >>> mydata.number
  42

Of course, values you get from a local object, including a __dict__
attribute, are for whatever thread was current at the time the
attribute was read.  For that reason, you generally don't want to save
these values across threads, as they apply only to the thread they
came from.

You can create custom local objects by subclassing the local class:

  >>> class MyLocal(local):
  ...     number = 2
  ...     def __init__(self, /, **kw):
  ...         self.__dict__.update(kw)
  ...     def squared(self):
  ...         return self.number ** 2

This can be useful to support default values, methods and
initialization.  Note that if you define an __init__ method, it will be
called each time the local object is used in a separate thread.  This
is necessary to initialize each thread's dictionary.

Now if we create a local object:

  >>> mydata = MyLocal(color='red')

Now we have a default number:

  >>> mydata.number
  2

an initial color:

  >>> mydata.color
  'red'
  >>> del mydata.color

And a method that operates on the data:

  >>> mydata.squared()
  4

As before, we can access the data in a separate thread:

  >>> log = []
  >>> thread = threading.Thread(target=f)
  >>> thread.start()
  >>> thread.join()
  >>> log
  [[('color', 'red')], 11]

without affecting this thread's data:

  >>> mydata.number
  2
  >>> mydata.color
  Traceback (most recent call last):
  ...
  AttributeError: 'MyLocal' object has no attribute 'color'

Note that subclasses can define slots, but they are not thread
local. They are shared across threads:

  >>> class MyLocal(local):
  ...     __slots__ = 'number'

  >>> mydata = MyLocal()
  >>> mydata.number = 42
  >>> mydata.color = 'red'

So, the separate thread:

  >>> thread = threading.Thread(target=f)
  >>> thread.start()
  >>> thread.join()

affects what we see:

  >>> mydata.number
  11

>>> del mydata
"""

from weakref import ref
from contextlib import contextmanager

__all__ = ["local"]

# We need to use objects from the threading module, but the threading
# module may also want to use our `local` class, if support for locals
# isn't compiled in to the `thread` module.  This creates potential problems
# with circular imports.  For that reason, we don't import `threading`
# until the bottom of this file (a hack sufficient to worm around the
# potential problems).  Note that all platforms on CPython do have support
# for locals in the `thread` module, and there is no circular import problem
# then, so problems introduced by fiddling the order of imports here won't
# manifest.

class _localimpl:
    """A class managing thread-local dicts"""
    __slots__ = 'key', 'dicts', 'localargs', 'locallock', '__weakref__'

    def __init__(self):
        # The key used in the Thread objects' attribute dicts.
        # We keep it a string for speed but make it unlikely to clash with
        # a "real" attribute.
        self.key = '_threading_local._localimpl.' + str(id(self))
        # { id(Thread) -> (ref(Thread), thread-local dict) }
        self.dicts = {}

    def get_dict(self):
        """Return the dict for the current thread. Raises KeyError if none
        defined."""
        thread = current_thread()
        return self.dicts[id(thread)][1]

    def create_dict(self):
        """Create a new dict for the current thread, and return it."""
        localdict = {}
        key = self.key
        thread = current_thread()
        idt = id(thread)
        def local_deleted(_, key=key):
            # When the localimpl is deleted, remove the thread attribute.
            thread = wrthread()
            if thread is not None:
                del thread.__dict__[key]
        def thread_deleted(_, idt=idt):
            # When the thread is deleted, remove the local dict.
            # Note that this is suboptimal if the thread object gets
            # caught in a reference loop. We would like to be called
            # as soon as the OS-level thread ends instead.
            local = wrlocal()
            if local is not None:
                dct = local.dicts.pop(idt)
        wrlocal = ref(self, local_deleted)
        wrthread = ref(thread, thread_deleted)
        thread.__dict__[key] = wrlocal
        self.dicts[idt] = wrthread, localdict
        return localdict


@contextmanager
def _patch(self):
    impl = object.__getattribute__(self, '_local__impl')
    try:
        dct = impl.get_dict()
    except KeyError:
        dct = impl.create_dict()
        args, kw = impl.localargs
        self.__init__(*args, **kw)
    with impl.locallock:
        object.__setattr__(self, '__dict__', dct)
        yield


class local:
    __slots__ = '_local__impl', '__dict__'

    def __new__(cls, /, *args, **kw):
        if (args or kw) and (cls.__init__ is object.__init__):
            raise TypeError("Initialization arguments are not supported")
        self = object.__new__(cls)
        impl = _localimpl()
        impl.localargs = (args, kw)
        impl.locallock = RLock()
        object.__setattr__(self, '_local__impl', impl)
        # We need to create the thread dict in anticipation of
        # __init__ being called, to make sure we don't call it
        # again ourselves.
        impl.create_dict()
        return self

    def __getattribute__(self, name):
        with _patch(self):
            return object.__getattribute__(self, name)

    def __setattr__(self, name, value):
        if name == '__dict__':
            raise AttributeError(
                "%r object attribute '__dict__' is read-only"
                % self.__class__.__name__)
        with _patch(self):
            return object.__setattr__(self, name, value)

    def __delattr__(self, name):
        if name == '__dict__':
            raise AttributeError(
                "%r object attribute '__dict__' is read-only"
                % self.__class__.__name__)
        with _patch(self):
            return object.__delattr__(self, name)


from threading import current_thread, RLock

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Mar 2026 4.04 PM
root / root
0555
__pycache__
--
21 Oct 2025 6.55 AM
root / root
0755
asyncio
--
21 Oct 2025 6.55 AM
root / root
0755
collections
--
21 Oct 2025 6.55 AM
root / root
0755
concurrent
--
21 Oct 2025 6.55 AM
root / root
0755
config-3.8-x86_64-linux-gnu
--
21 Oct 2025 6.55 AM
root / root
0755
ctypes
--
21 Oct 2025 6.55 AM
root / root
0755
curses
--
21 Oct 2025 6.55 AM
root / root
0755
dbm
--
21 Oct 2025 6.55 AM
root / root
0755
distutils
--
21 Oct 2025 6.55 AM
root / root
0755
email
--
21 Oct 2025 6.55 AM
root / root
0755
encodings
--
21 Oct 2025 6.55 AM
root / root
0755
ensurepip
--
21 Oct 2025 6.55 AM
root / root
0755
html
--
21 Oct 2025 6.55 AM
root / root
0755
http
--
21 Oct 2025 6.55 AM
root / root
0755
importlib
--
21 Oct 2025 6.55 AM
root / root
0755
json
--
21 Oct 2025 6.55 AM
root / root
0755
lib-dynload
--
21 Oct 2025 6.55 AM
root / root
0755
lib2to3
--
21 Oct 2025 6.55 AM
root / root
0755
logging
--
21 Oct 2025 6.55 AM
root / root
0755
multiprocessing
--
21 Oct 2025 6.55 AM
root / root
0755
pydoc_data
--
21 Oct 2025 6.55 AM
root / root
0755
site-packages
--
21 Oct 2025 6.55 AM
root / root
0755
sqlite3
--
21 Oct 2025 6.55 AM
root / root
0755
unittest
--
21 Oct 2025 6.55 AM
root / root
0755
urllib
--
21 Oct 2025 6.55 AM
root / root
0755
venv
--
21 Oct 2025 6.55 AM
root / root
0755
wsgiref
--
21 Oct 2025 6.55 AM
root / root
0755
xml
--
21 Oct 2025 6.55 AM
root / root
0755
xmlrpc
--
21 Oct 2025 6.55 AM
root / root
0755
LICENSE.txt
13.61 KB
6 Jun 2023 1.32 PM
root / root
0644
__future__.py
5.026 KB
6 Jun 2023 1.32 PM
root / root
0644
__phello__.foo.py
0.063 KB
6 Jun 2023 1.32 PM
root / root
0644
_bootlocale.py
1.759 KB
6 Jun 2023 1.32 PM
root / root
0644
_collections_abc.py
25.488 KB
6 Jun 2023 1.32 PM
root / root
0644
_compat_pickle.py
8.544 KB
6 Jun 2023 1.32 PM
root / root
0644
_compression.py
5.215 KB
6 Jun 2023 1.32 PM
root / root
0644
_dummy_thread.py
5.886 KB
6 Jun 2023 1.32 PM
root / root
0644
_markupbase.py
14.256 KB
6 Jun 2023 1.32 PM
root / root
0644
_osx_support.py
21.264 KB
6 Jun 2023 1.32 PM
root / root
0644
_py_abc.py
6.044 KB
6 Jun 2023 1.32 PM
root / root
0644
_pydecimal.py
223.307 KB
6 Jun 2023 1.32 PM
root / root
0644
_pyio.py
90.993 KB
6 Jun 2023 1.32 PM
root / root
0644
_sitebuiltins.py
3.042 KB
6 Jun 2023 1.32 PM
root / root
0644
_strptime.py
24.676 KB
6 Jun 2023 1.32 PM
root / root
0644
_sysconfigdata__linux_x86_64-linux-gnu.py
37.607 KB
17 Oct 2023 6.12 PM
root / root
0644
_sysconfigdata_d_linux_x86_64-linux-gnu.py
37.341 KB
17 Oct 2023 6.03 PM
root / root
0644
_threading_local.py
7.051 KB
6 Jun 2023 1.32 PM
root / root
0644
_weakrefset.py
5.601 KB
6 Jun 2023 1.32 PM
root / root
0644
abc.py
4.384 KB
6 Jun 2023 1.32 PM
root / root
0644
aifc.py
32.045 KB
6 Jun 2023 1.32 PM
root / root
0644
antigravity.py
0.466 KB
6 Jun 2023 1.32 PM
root / root
0644
argparse.py
93.765 KB
6 Jun 2023 1.32 PM
root / root
0644
ast.py
18.783 KB
6 Jun 2023 1.32 PM
root / root
0644
asynchat.py
11.063 KB
6 Jun 2023 1.32 PM
root / root
0644
asyncore.py
19.623 KB
6 Jun 2023 1.32 PM
root / root
0644
base64.py
19.904 KB
6 Jun 2023 1.32 PM
root / root
0755
bdb.py
31.305 KB
6 Jun 2023 1.32 PM
root / root
0644
binhex.py
13.627 KB
6 Jun 2023 1.32 PM
root / root
0644
bisect.py
2.162 KB
6 Jun 2023 1.32 PM
root / root
0644
bz2.py
12.264 KB
6 Jun 2023 1.32 PM
root / root
0644
cProfile.py
6.846 KB
6 Jun 2023 1.32 PM
root / root
0755
calendar.py
24.25 KB
6 Jun 2023 1.32 PM
root / root
0644
cgi.py
33.139 KB
17 Oct 2023 6.02 PM
root / root
0755
cgitb.py
11.813 KB
6 Jun 2023 1.32 PM
root / root
0644
chunk.py
5.308 KB
6 Jun 2023 1.32 PM
root / root
0644
cmd.py
14.512 KB
6 Jun 2023 1.32 PM
root / root
0644
code.py
10.373 KB
6 Jun 2023 1.32 PM
root / root
0644
codecs.py
35.808 KB
6 Jun 2023 1.32 PM
root / root
0644
codeop.py
6.182 KB
6 Jun 2023 1.32 PM
root / root
0644
colorsys.py
3.969 KB
6 Jun 2023 1.32 PM
root / root
0644
compileall.py
13.357 KB
6 Jun 2023 1.32 PM
root / root
0644
configparser.py
53.1 KB
6 Jun 2023 1.32 PM
root / root
0644
contextlib.py
24.409 KB
6 Jun 2023 1.32 PM
root / root
0644
contextvars.py
0.126 KB
6 Jun 2023 1.32 PM
root / root
0644
copy.py
8.458 KB
6 Jun 2023 1.32 PM
root / root
0644
copyreg.py
6.968 KB
6 Jun 2023 1.32 PM
root / root
0644
crypt.py
3.525 KB
6 Jun 2023 1.32 PM
root / root
0644
csv.py
15.766 KB
6 Jun 2023 1.32 PM
root / root
0644
dataclasses.py
48.802 KB
6 Jun 2023 1.32 PM
root / root
0644
datetime.py
86.218 KB
6 Jun 2023 1.32 PM
root / root
0644
decimal.py
0.313 KB
6 Jun 2023 1.32 PM
root / root
0644
difflib.py
82.088 KB
6 Jun 2023 1.32 PM
root / root
0644
dis.py
20.088 KB
6 Jun 2023 1.32 PM
root / root
0644
doctest.py
102.093 KB
6 Jun 2023 1.32 PM
root / root
0644
dummy_threading.py
2.749 KB
6 Jun 2023 1.32 PM
root / root
0644
enum.py
37.242 KB
6 Jun 2023 1.32 PM
root / root
0644
filecmp.py
9.6 KB
6 Jun 2023 1.32 PM
root / root
0644
fileinput.py
14.364 KB
6 Jun 2023 1.32 PM
root / root
0644
fnmatch.py
3.983 KB
6 Jun 2023 1.32 PM
root / root
0644
formatter.py
14.788 KB
6 Jun 2023 1.32 PM
root / root
0644
fractions.py
23.759 KB
6 Jun 2023 1.32 PM
root / root
0644
ftplib.py
34.306 KB
6 Jun 2023 1.32 PM
root / root
0644
functools.py
36.529 KB
6 Jun 2023 1.32 PM
root / root
0644
genericpath.py
4.858 KB
6 Jun 2023 1.32 PM
root / root
0644
getopt.py
7.313 KB
6 Jun 2023 1.32 PM
root / root
0644
getpass.py
5.854 KB
6 Jun 2023 1.32 PM
root / root
0644
gettext.py
26.502 KB
6 Jun 2023 1.32 PM
root / root
0644
glob.py
5.563 KB
6 Jun 2023 1.32 PM
root / root
0644
gzip.py
20.911 KB
6 Jun 2023 1.32 PM
root / root
0644
hashlib.py
8.138 KB
17 Oct 2023 6.02 PM
root / root
0644
heapq.py
22.341 KB
6 Jun 2023 1.32 PM
root / root
0644
hmac.py
7.666 KB
17 Oct 2023 6.02 PM
root / root
0644
imaplib.py
52.35 KB
6 Jun 2023 1.32 PM
root / root
0644
imghdr.py
3.719 KB
6 Jun 2023 1.32 PM
root / root
0644
imp.py
10.289 KB
6 Jun 2023 1.32 PM
root / root
0644
inspect.py
115.771 KB
6 Jun 2023 1.32 PM
root / root
0644
io.py
3.458 KB
6 Jun 2023 1.32 PM
root / root
0644
ipaddress.py
69.965 KB
6 Jun 2023 1.32 PM
root / root
0644
keyword.py
0.923 KB
6 Jun 2023 1.32 PM
root / root
0644
linecache.py
5.205 KB
6 Jun 2023 1.32 PM
root / root
0644
locale.py
76.358 KB
6 Jun 2023 1.32 PM
root / root
0644
lzma.py
12.679 KB
6 Jun 2023 1.32 PM
root / root
0644
mailbox.py
76.817 KB
6 Jun 2023 1.32 PM
root / root
0644
mailcap.py
8.854 KB
6 Jun 2023 1.32 PM
root / root
0644
mimetypes.py
21.156 KB
6 Jun 2023 1.32 PM
root / root
0644
modulefinder.py
23.857 KB
6 Jun 2023 1.32 PM
root / root
0644
netrc.py
5.436 KB
6 Jun 2023 1.32 PM
root / root
0644
nntplib.py
42.247 KB
6 Jun 2023 1.32 PM
root / root
0644
ntpath.py
27.084 KB
6 Jun 2023 1.32 PM
root / root
0644
nturl2path.py
2.819 KB
6 Jun 2023 1.32 PM
root / root
0644
numbers.py
10.004 KB
6 Jun 2023 1.32 PM
root / root
0644
opcode.py
5.672 KB
6 Jun 2023 1.32 PM
root / root
0644
operator.py
10.46 KB
6 Jun 2023 1.32 PM
root / root
0644
optparse.py
58.954 KB
6 Jun 2023 1.32 PM
root / root
0644
os.py
38.081 KB
6 Jun 2023 1.32 PM
root / root
0644
pathlib.py
51.377 KB
6 Jun 2023 1.32 PM
root / root
0644
pdb.py
61.268 KB
6 Jun 2023 1.32 PM
root / root
0755
pickle.py
62.956 KB
6 Jun 2023 1.32 PM
root / root
0644
pickletools.py
91.295 KB
6 Jun 2023 1.32 PM
root / root
0644
pipes.py
8.707 KB
6 Jun 2023 1.32 PM
root / root
0644
pkgutil.py
20.996 KB
6 Jun 2023 1.32 PM
root / root
0644
platform.py
39.478 KB
6 Jun 2023 1.32 PM
root / root
0755
plistlib.py
31.465 KB
6 Jun 2023 1.32 PM
root / root
0644
poplib.py
14.724 KB
6 Jun 2023 1.32 PM
root / root
0644
posixpath.py
15.261 KB
6 Jun 2023 1.32 PM
root / root
0644
pprint.py
20.98 KB
6 Jun 2023 1.32 PM
root / root
0644
profile.py
22.994 KB
6 Jun 2023 1.32 PM
root / root
0755
pstats.py
26.704 KB
6 Jun 2023 1.32 PM
root / root
0644
pty.py
4.694 KB
6 Jun 2023 1.32 PM
root / root
0644
py_compile.py
8.011 KB
17 Oct 2023 6.02 PM
root / root
0644
pyclbr.py
14.897 KB
6 Jun 2023 1.32 PM
root / root
0644
pydoc.py
104.199 KB
17 Oct 2023 6.12 PM
root / root
0644
queue.py
11.09 KB
6 Jun 2023 1.32 PM
root / root
0644
quopri.py
7.082 KB
6 Jun 2023 1.32 PM
root / root
0755
random.py
28.127 KB
6 Jun 2023 1.32 PM
root / root
0644
re.py
15.489 KB
6 Jun 2023 1.32 PM
root / root
0644
reprlib.py
5.144 KB
6 Jun 2023 1.32 PM
root / root
0644
rlcompleter.py
6.931 KB
6 Jun 2023 1.32 PM
root / root
0644
runpy.py
11.77 KB
6 Jun 2023 1.32 PM
root / root
0644
sched.py
6.291 KB
6 Jun 2023 1.32 PM
root / root
0644
secrets.py
1.99 KB
6 Jun 2023 1.32 PM
root / root
0644
selectors.py
18.126 KB
6 Jun 2023 1.32 PM
root / root
0644
shelve.py
8.327 KB
6 Jun 2023 1.32 PM
root / root
0644
shlex.py
13.013 KB
6 Jun 2023 1.32 PM
root / root
0644
shutil.py
50.548 KB
6 Jun 2023 1.32 PM
root / root
0644
signal.py
2.22 KB
6 Jun 2023 1.32 PM
root / root
0644
site.py
21.326 KB
17 Oct 2023 6.02 PM
root / root
0644
smtpd.py
33.896 KB
6 Jun 2023 1.32 PM
root / root
0755
smtplib.py
43.946 KB
6 Jun 2023 1.32 PM
root / root
0755
sndhdr.py
6.933 KB
6 Jun 2023 1.32 PM
root / root
0644
socket.py
34.417 KB
6 Jun 2023 1.32 PM
root / root
0644
socketserver.py
26.656 KB
6 Jun 2023 1.32 PM
root / root
0644
sre_compile.py
26.069 KB
6 Jun 2023 1.32 PM
root / root
0644
sre_constants.py
6.986 KB
6 Jun 2023 1.32 PM
root / root
0644
sre_parse.py
39.287 KB
6 Jun 2023 1.32 PM
root / root
0644
ssl.py
49.57 KB
6 Jun 2023 1.32 PM
root / root
0644
stat.py
5.356 KB
6 Jun 2023 1.32 PM
root / root
0644
statistics.py
38.76 KB
6 Jun 2023 1.32 PM
root / root
0644
string.py
10.288 KB
6 Jun 2023 1.32 PM
root / root
0644
stringprep.py
12.614 KB
6 Jun 2023 1.32 PM
root / root
0644
struct.py
0.251 KB
6 Jun 2023 1.32 PM
root / root
0644
subprocess.py
76.416 KB
6 Jun 2023 1.32 PM
root / root
0644
sunau.py
17.944 KB
6 Jun 2023 1.32 PM
root / root
0644
symbol.py
2.06 KB
17 Oct 2023 6.04 PM
root / root
0644
symtable.py
7.833 KB
6 Jun 2023 1.32 PM
root / root
0644
sysconfig.py
24.313 KB
17 Oct 2023 6.12 PM
root / root
0644
tabnanny.py
11.139 KB
6 Jun 2023 1.32 PM
root / root
0755
tarfile.py
103.978 KB
17 Oct 2023 6.02 PM
root / root
0755
telnetlib.py
22.709 KB
6 Jun 2023 1.32 PM
root / root
0644
tempfile.py
26.892 KB
6 Jun 2023 1.32 PM
root / root
0644
textwrap.py
18.952 KB
6 Jun 2023 1.32 PM
root / root
0644
this.py
0.979 KB
6 Jun 2023 1.32 PM
root / root
0644
threading.py
49.629 KB
6 Jun 2023 1.32 PM
root / root
0644
timeit.py
13.164 KB
6 Jun 2023 1.32 PM
root / root
0755
token.py
2.313 KB
6 Jun 2023 1.32 PM
root / root
0644
tokenize.py
25.235 KB
6 Jun 2023 1.32 PM
root / root
0644
trace.py
29.17 KB
6 Jun 2023 1.32 PM
root / root
0755
traceback.py
23.058 KB
6 Jun 2023 1.32 PM
root / root
0644
tracemalloc.py
16.676 KB
6 Jun 2023 1.32 PM
root / root
0644
tty.py
0.858 KB
6 Jun 2023 1.32 PM
root / root
0644
types.py
9.485 KB
6 Jun 2023 1.32 PM
root / root
0644
typing.py
67.346 KB
6 Jun 2023 1.32 PM
root / root
0644
uu.py
7.106 KB
17 Oct 2023 6.12 PM
root / root
0644
uuid.py
29.8 KB
17 Oct 2023 6.02 PM
root / root
0644
warnings.py
19.227 KB
6 Jun 2023 1.32 PM
root / root
0644
wave.py
17.803 KB
6 Jun 2023 1.32 PM
root / root
0644
weakref.py
20.886 KB
6 Jun 2023 1.32 PM
root / root
0644
webbrowser.py
23.519 KB
6 Jun 2023 1.32 PM
root / root
0755
xdrlib.py
5.774 KB
6 Jun 2023 1.32 PM
root / root
0644
zipapp.py
7.358 KB
6 Jun 2023 1.32 PM
root / root
0644
zipfile.py
85.672 KB
6 Jun 2023 1.32 PM
root / root
0644
zipimport.py
30.044 KB
6 Jun 2023 1.32 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF