class TracingFunctionHolder: '''This class exists just to keep some variables (so that we don't keep them in the global namespace). ''' _original_tracing = None _warn = True _lock = threading.Lock() _traceback_limit = 1 _warnings_shown = {}
def __init__(self, maxsize=0): self.maxsize = maxsize self._init(maxsize) # mutex must be held whenever the queue is mutating. All methods # that acquire mutex must release it before returning. mutex # is shared between the three conditions, so acquiring and # releasing the conditions also acquires and releases mutex. self.mutex = _threading.Lock() # Notify not_empty whenever an item is added to the queue; a # thread waiting to get is notified then. self.not_empty = _threading.Condition(self.mutex) # Notify not_full whenever an item is removed from the queue; # a thread waiting to put is notified then. self.not_full = _threading.Condition(self.mutex) # Notify all_tasks_done whenever the number of unfinished tasks # drops to zero; thread waiting to join() is notified to resume self.all_tasks_done = _threading.Condition(self.mutex) self.unfinished_tasks = 0
def __init__(self): AbstractPyDBAdditionalThreadInfo.__init__(self) #That's where the last frame entered is kept. That's needed so that we're able to #trace contexts that were previously untraced and are currently active. So, the bad thing #is that the frame may be kept alive longer than it would if we go up on the frame stack, #and is only disposed when some other frame is removed. #A better way would be if we could get the topmost frame for each thread, but that's #not possible (until python 2.5 -- which is the PyDBAdditionalThreadInfoWithCurrentFramesSupport version) #Or if the user compiled threadframe (from http://www.majid.info/mylos/stories/2004/06/10/threadframe.html) #NOT RLock!! (could deadlock if it was) self.lock = threading.Lock() self._acquire_lock = self.lock.acquire self._release_lock = self.lock.release #collection with the refs d = {} self.pydev_existing_frames = d try: self._iter_frames = d.iterkeys except AttributeError: self._iter_frames = d.keys
try: import struct IS_64_BITS = struct.calcsize("P") * 8 > 32 except: IS_64_BITS = False SUPPORT_GEVENT = os.getenv('GEVENT_SUPPORT', 'False') == 'True' USE_LIB_COPY = SUPPORT_GEVENT and not IS_PY3K and sys.version_info[1] >= 6 if USE_LIB_COPY: import _pydev_threading as threading else: import threading _nextThreadIdLock = threading.Lock() #======================================================================================================================= # Jython? #======================================================================================================================= try: import org.python.core.PyDictionary #@UnresolvedImport @UnusedImport -- just to check if it could be valid def DictContains(d, key): return d.has_key(key) except: try: #Py3k does not have has_key anymore, and older versions don't have __contains__ DictContains = dict.__contains__ except: try:
class AdditionalFramesContainer: lock = threading.Lock() additional_frames = {} #dict of dicts
def __init__(self, module_name, thread_id): self.thread_id = thread_id self.module_name = module_name self.executed = False self.lock = threading.Lock()