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


Python threading._get_ident函数代码示例

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


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

示例1: get_cache_con

def get_cache_con():
	if not cache_con_map.has_key(threading._get_ident()):
		cache_con = sqlite.connect(":memory:")
		cur = cache_con.cursor()
		cur.execute("create table plugin_result_cache(url string, timestamp long, content string)")
		cur.close()
		cache_con_map[threading._get_ident()] = cache_con
	con = cache_con_map[threading._get_ident()]
	return con
开发者ID:maxezek,项目名称:max-desktop,代码行数:9,代码来源:plugin-finder.py

示例2: findphoto

def findphoto(bs,url):
    global x
    jieguo=bs.findAll(name ="img",attrs={"src":re.compile(r"^http://")})  #re.compile(r"^http://")
    for temp in jieguo:
        print "find picture %s"% temp["src"]
        print threading._get_ident()
        if(re.compile(r"http://").findall(temp["src"])):
            download(temp["src"])                            #下载方式一
        else:
            print "\n\n\n\n\n\n\n"
            b=urlparse.urlparse(url)
            tempurl=b[0]+r"://"+b[1]+r"/"+temp["src"]
            print tempurl
            download(tempurl)
开发者ID:Iamgublin,项目名称:python-related,代码行数:14,代码来源:PythonApplication4.py

示例3: request

    def request(self, clientAddress, remoteHost, scheme="http"):
        """Obtain an HTTP Request object.
        
        clientAddress: the (IP address, port) of the client
        remoteHost: the IP address of the client
        scheme: either "http" or "https"; defaults to "http"
        """
        if self.state == STOPPED:
            raise cherrypy.NotReady("The CherryPy server has stopped.")
        elif self.state == STARTING:
            raise cherrypy.NotReady("The CherryPy server could not start.")

        threadID = threading._get_ident()
        if threadID not in self.seen_threads:

            if cherrypy.codecoverage:
                from cherrypy.lib import covercp

                covercp.start()

            i = len(self.seen_threads) + 1
            self.seen_threads[threadID] = i

            for func in self.on_start_thread_list:
                func(i)

        r = self.request_class(clientAddress[0], clientAddress[1], remoteHost, scheme)
        cherrypy.serving.request = r
        cherrypy.serving.response = self.response_class()
        return r
开发者ID:thraxil,项目名称:gtreed,代码行数:30,代码来源:_cpengine.py

示例4: get_repository

 def get_repository(self, authname):
     if not self._connector:
         candidates = []
         for connector in self.connectors:
             for repos_type_, prio in connector.get_supported_types():
                 if self.repository_type != repos_type_:
                     continue
                 heappush(candidates, (-prio, connector))
         if not candidates:
             raise TracError('Unsupported version control system "%s". '
                             'Check that the Python bindings for "%s" are '
                             'correctly installed.' %
                             ((self.repository_type,)*2))
         self._connector = heappop(candidates)[1]
     db = self.env.get_db_cnx() # prevent possible deadlock, see #4465
     try:
         self._lock.acquire()
         tid = threading._get_ident()
         if tid in self._cache:
             repos = self._cache[tid]
         else:
             rtype, rdir = self.repository_type, self.repository_dir
             repos = self._connector.get_repository(rtype, rdir, authname)
             self._cache[tid] = repos
         return repos
     finally:
         self._lock.release()
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:27,代码来源:api.py

示例5: currentThread

def currentThread():
    from threading import _get_ident, _active, _DummyThread

    try:
        return _active[_get_ident()]
    except KeyError:
        return _DummyThread()
开发者ID:lhl,项目名称:songclub,代码行数:7,代码来源:reflect.py

示例6: release

 def release(self):
     if self.__owner != _get_ident():
         raise RuntimeError("cannot release un-aquired lock")
     self.__count -= 1
     if not self.__count:
         self.__owner = None
         self.__block.release()
开发者ID:rfk,项目名称:threading2,代码行数:7,代码来源:t2_base.py

示例7: request

 def request(self, local_host, remote_host, scheme="http",
             server_protocol="HTTP/1.1"):
     """Obtain and return an HTTP Request object. (Core)
     
     local_host should be an http.Host object with the server info.
     remote_host should be an http.Host object with the client info.
     scheme: either "http" or "https"; defaults to "http"
     """
     if self.state == STOPPED:
         req = NotReadyRequest("The CherryPy engine has stopped.")
     elif self.state == STARTING:
         req = NotReadyRequest("The CherryPy engine could not start.")
     else:
         # Only run on_start_thread_list if the engine is running.
         threadID = threading._get_ident()
         if threadID not in self.seen_threads:
             i = len(self.seen_threads) + 1
             self.seen_threads[threadID] = i
             
             for func in self.on_start_thread_list:
                 func(i)
         req = self.request_class(local_host, remote_host, scheme,
                                  server_protocol)
     resp = self.response_class()
     cherrypy.serving.load(req, resp)
     self.servings.append((req, resp))
     return req
开发者ID:Juanvvc,项目名称:scfs,代码行数:27,代码来源:_cpengine.py

示例8: __bootstrap

  def __bootstrap(self):
    try:
      self._set_ident()
      self._Thread__started.set()
      threading._active_limbo_lock.acquire()
      threading._active[self._Thread__ident] = self
      del threading._limbo[self]
      threading._active_limbo_lock.release()

      if threading._trace_hook:
        sys.settrace(threading._trace_hook)
      if threading._profile_hook:
        sys.setprofile(threading._profile_hook)

      try:
        self.run()
      finally:
        self._Thread__exc_clear()
    finally:
      with threading._active_limbo_lock:
        self._Thread__stop()
        try:
          del threading._active[threading._get_ident()]
        except:
          pass
开发者ID:0xmilk,项目名称:appscale,代码行数:25,代码来源:background_thread.py

示例9: get_connection

 def get_connection(self):
     key = self.dbpath + str(threading._get_ident())
     if key in _MAP_OF_CONNECTIONS:
         return _MAP_OF_CONNECTIONS[key]
     conn = sqlite3.connect(self.dbpath)
     print "Trying to open", self.dbpath
     _MAP_OF_CONNECTIONS[key] = conn
     return conn
开发者ID:jayalane,项目名称:persist_wrapper,代码行数:8,代码来源:persist_dict.py

示例10: shutdown

 def shutdown(self, tid=None):
     if tid:
         assert tid == threading._get_ident()
         try:
             self._lock.acquire()
             self._cache.pop(tid, None)
         finally:
             self._lock.release()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:8,代码来源:api.py

示例11: getInstance

    def getInstance(create=True):
        tid = threading._get_ident()
        instance = DALManager._instances.get(tid)

        if not instance and create:
            minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
            instance = DBConnection(minfo)
            DALManager._instances[tid] = instance
        return instance
开发者ID:bubbas,项目名称:indico,代码行数:9,代码来源:dalManager.py

示例12: startRequest

    def startRequest( self ):
        """Initialise the DB and starts a new transaction.
        """

        conn = self._getConnObject()
        if conn is None:
            self._conn[threading._get_ident()]=self._db.open()
            Logger.get('dbmgr').debug('Allocated connection for thread %s - table size is %s' % (threading._get_ident(), len(self._conn)))
        else:
            Logger.get('dbmgr').debug('Reused connection for thread %s - table size is %s' % (threading._get_ident(), len(self._conn)))
开发者ID:davidmorrison,项目名称:indico,代码行数:10,代码来源:db.py

示例13: acquire

 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
开发者ID:rfk,项目名称:threading2,代码行数:10,代码来源:t2_base.py

示例14: gotThreadMsg

	def gotThreadMsg(self, msg=None):
		
		from ctypes import CDLL
		SYS_gettid = 4222
		libc = CDLL("libc.so.6")
		tid = libc.syscall(SYS_gettid)
		splog('SP: Worker got message: ', currentThread(), _get_ident(), self.ident, os.getpid(), tid )
		
		data = self.__messages.pop()
		if callable(self.callback):
			self.callback(data)
开发者ID:Linux-Box,项目名称:enigma2-plugins,代码行数:11,代码来源:SeriesPlugin.py

示例15: __repr__

 def __repr__(self, _repr_running={}):
     'od.__repr__() <==> repr(od)'
     call_key = id(self), _get_ident()
     if call_key in _repr_running:
         return '...'
     _repr_running[call_key] = 1
     try:
         if not self:
             return '%s()' % (self.__class__.__name__,)
         return '%s(%r)' % (self.__class__.__name__, self.items())
     finally:
         del _repr_running[call_key]
开发者ID:asterisk,项目名称:asterisk,代码行数:12,代码来源:astdicts.py


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