Package trac :: Package util :: Module concurrency

Source Code for Module trac.util.concurrency

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (C) 2010-2023 Edgewall Software 
 4  # All rights reserved. 
 5  # 
 6  # This software is licensed as described in the file COPYING, which 
 7  # you should have received as part of this distribution. The terms 
 8  # are also available at https://trac.edgewall.org/wiki/TracLicense. 
 9  # 
10  # This software consists of voluntary contributions made by many 
11  # individuals. For the exact contribution history, see the revision 
12  # history and logs, available at https://trac.edgewall.org/log/. 
13   
14  try: 
15      import threading 
16  except ImportError: 
17      import dummy_threading as threading 
18      threading._get_ident = lambda: 0 
19   
20   
21 -class ThreadLocal(threading.local):
22 """A thread-local storage allowing to set default values on construction. 23 """
24 - def __init__(self, **kwargs):
25 threading.local.__init__(self) 26 self.__dict__.update(kwargs)
27 28 29 try: 30 threading.get_ident # since Python 3.3 31 except AttributeError: 32 get_thread_id = threading._get_ident 33 else: 34 get_thread_id = threading.get_ident 35