当前位置: 首页>>代码示例>>Python>>正文


Python ll_thread.get_ident函数代码示例

本文整理汇总了Python中pypy.module.thread.ll_thread.get_ident函数的典型用法代码示例。如果您正苦于以下问题:Python get_ident函数的具体用法?Python get_ident怎么用?Python get_ident使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_ident函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setdict

 def setdict(self, space, w_dict):
     if not space.is_true(space.isinstance(w_dict, space.w_dict)):
         raise OperationError(space.w_TypeError,
                             space.wrap("setting dictionary to a non-dict"))
     self.getdict()   # force a dict to exist first
     ident = thread.get_ident()
     self.dicts[ident] = w_dict
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:os_local.py

示例2: f

 def f():
     state.data = []
     state.threadlocals = gil.GILThreadLocals()
     state.threadlocals.setup_threads(space)
     thread.gc_thread_prepare()
     subident = thread.start_new_thread(bootstrap, ())
     mainident = thread.get_ident()
     runme()
     still_waiting = 3000
     while len(state.data) < 2*N:
         if not still_waiting:
             raise ValueError("time out")
         still_waiting -= 1
         if not we_are_translated(): gil.before_external_call()
         time.sleep(0.01)
         if not we_are_translated(): gil.after_external_call()
     i1 = i2 = 0
     for tid, i in state.data:
         if tid == mainident:
             assert i == i1; i1 += 1
         elif tid == subident:
             assert i == i2; i2 += 1
         else:
             assert 0
     assert i1 == N
     assert i2 == N
     return len(state.data)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:27,代码来源:test_gil.py

示例3: run

 def run(space, w_callable, args):
     try:
         space.call_args(w_callable, args)
     except OperationError, e:
         if not e.match(space, space.w_SystemExit):
             ident = thread.get_ident()
             where = 'thread %d started by ' % ident
             e.write_unraisable(space, where, w_callable)
         e.clear(space)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:9,代码来源:os_thread.py

示例4: get_ident

def get_ident(space):
    """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."""
    ident = thread.get_ident()
    return space.wrap(ident)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:10,代码来源:os_thread.py

示例5: getvalue

 def getvalue(self):
     ident = thread.get_ident()
     if ident == self._mostrecentkey:
         result = self._mostrecentvalue
     else:
         value = self._valuedict.get(ident, None)
         # slow path: update the minicache
         self._mostrecentkey = ident
         self._mostrecentvalue = value
         result = value
     return result
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:threadlocals.py

示例6: setvalue

 def setvalue(self, value):
     ident = thread.get_ident()
     if value is not None:
         if len(self._valuedict) == 0:
             self._mainthreadident = ident
         self._valuedict[ident] = value
     else:
         try:
             del self._valuedict[ident]
         except KeyError:
             pass
开发者ID:antoine1fr,项目名称:pygirl,代码行数:11,代码来源:threadlocals.py

示例7: leave_thread

 def leave_thread(self, space):
     "Notification that the current thread is about to stop."
     try:
         ec = space.getexecutioncontext()
         while ec.thread_exit_funcs:
             exit_func, w_obj = ec.thread_exit_funcs.pop()
             exit_func(w_obj)
     finally:
         ident = thread.get_ident()
         try:
             del self._valuedict[ident]
         except KeyError:
             pass
开发者ID:antoine1fr,项目名称:pygirl,代码行数:13,代码来源:threadlocals.py

示例8: setvalue

 def setvalue(self, value):
     ident = thread.get_ident()
     if value is not None:
         if len(self._valuedict) == 0:
             self._mainthreadident = ident
         self._valuedict[ident] = value
     else:
         try:
             del self._valuedict[ident]
         except KeyError:
             pass
     # update the minicache to prevent it from containing an outdated value
     self._mostrecentkey = ident
     self._mostrecentvalue = value
开发者ID:alkorzt,项目名称:pypy,代码行数:14,代码来源:threadlocals.py

示例9: runme

 def runme(main=False):
     j = 0
     for i in range(N + [-skew, skew][main]):
         state.datalen1 += 1   # try to crash if the GIL is not
         state.datalen2 += 1   # correctly acquired
         state.data.append((thread.get_ident(), i))
         state.datalen3 += 1
         state.datalen4 += 1
         assert state.datalen1 == len(state.data)
         assert state.datalen2 == len(state.data)
         assert state.datalen3 == len(state.data)
         assert state.datalen4 == len(state.data)
         debug_print(main, i, state.datalen4)
         gil.do_yield_thread()
         assert i == j
         j += 1
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:16,代码来源:test_gil.py

示例10: getdict

 def getdict(self, space):
     ident = thread.get_ident()
     try:
         w_dict = self.dicts[ident]
     except KeyError:
         # create a new dict for this thread
         w_dict = self.dicts[ident] = space.newdict(instance=True)
         # call __init__
         try:
             w_self = space.wrap(self)
             w_type = space.type(w_self)
             w_init = space.getattr(w_type, space.wrap("__init__"))
             space.call_obj_args(w_init, w_self, self.initargs)
         except:
             # failed, forget w_dict and propagate the exception
             del self.dicts[ident]
             raise
         # ready
         space.threadlocals.atthreadexit(space, finish_thread, self)
     return w_dict
开发者ID:Sherlockhlt,项目名称:pypy,代码行数:20,代码来源:os_local.py

示例11: PyThread_get_thread_ident

def PyThread_get_thread_ident(space):
    return ll_thread.get_ident()
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:2,代码来源:thread.py

示例12: __init__

 def __init__(self, space, initargs):
     self.initargs = initargs
     ident = thread.get_ident()
     self.dicts = {ident: space.newdict(instance=True)}
开发者ID:Sherlockhlt,项目名称:pypy,代码行数:4,代码来源:os_local.py

示例13: _ssl_thread_id_function

def _ssl_thread_id_function():
    from pypy.module.thread import ll_thread
    return rffi.cast(rffi.LONG, ll_thread.get_ident())
开发者ID:gorakhargosh,项目名称:pypy,代码行数:3,代码来源:interp_ssl.py

示例14: __init__

 def __init__(self, space, initargs):
     self.space = space
     self.initargs = initargs.normalize()
     ident = thread.get_ident()
     self.dicts = {ident: space.newdict()}
开发者ID:antoine1fr,项目名称:pygirl,代码行数:5,代码来源:os_local.py

示例15: finish_thread

def finish_thread(w_obj):
    assert isinstance(w_obj, Local)
    ident = thread.get_ident()
    del w_obj.dicts[ident]
开发者ID:antoine1fr,项目名称:pygirl,代码行数:4,代码来源:os_local.py


注:本文中的pypy.module.thread.ll_thread.get_ident函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。