All Samples(40) | Call(38) | Derive(0) | Import(2)
get_ident() -> integer Return a non-zero integer that uniquely identifies the current thread amongst other threads that exist simultaneously. This may be used to identify per-thread resources. Even though on some platforms threads identities may appear to be allocated consecutive numbers starting at 1, this behavior should not be relied upon, and the number should be seen purely as a magic cookie. A thread's identity may be reused for another thread after it exits.
src/t/h/threading2-0.1.4/threading2/t2_base.py threading2(Download)
import threading2
from threading import *
from threading import _RLock,_Event,_Condition,_Semaphore,_BoundedSemaphore, \
_Timer,ThreadError,_time,_sleep,_get_ident,_allocate_lock
def acquire(self,blocking=True,timeout=None):
me = _get_ident()
if self.__owner == me:
self.__count += 1
return True
if self.__block.acquire(blocking,timeout):
self.__owner = me
self.__count = 1
return True
return False
def release(self):
if self.__owner != _get_ident():
def _is_owned(self):
return self.__owner == _get_ident()
class Condition(_Condition):
"""Re-implemented Condition class.
def before_run(self):
self.__ident = _get_ident()
if self.__priority is not None:
self._set_priority(self.__priority)
@property
def ident(self):
return self.__ident
src/p/y/pypy-HEAD/pypy/lib/sqlite3/dbapi2.py pypy(Download)
import sys import time import weakref from threading import _get_ident as thread_get_ident apilevel = "2.0" paramstyle = "qmark"
self.NotSupportedError = NotSupportedError
self.func_cache = {}
self.thread_ident = thread_get_ident()
def _get_exception(self, error_code = None):
if error_code is None:
def _check_thread(self):
if self.thread_ident != thread_get_ident():
raise ProgrammingError(
"SQLite objects created in a thread can only be used in that same thread."
"The object was created in thread id %d and this is thread id %d",
self.thread_ident, thread_get_ident())