• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python threading._get_ident函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: release

 def release(self):
     if not self.is_locked:
         return False
     ident = threading._get_ident()
     ot = self.owner_thread
     if ident != self.current_owner:
         return False
     self.lock_count -= 1
     if self.lock_count == 0:
         self.current_owner = None
         self.__lock.release()
     return True
开发者ID:nocarryr,项目名称:node_mapper,代码行数:12,代码来源:threadbases.py


示例17: __ThreadIDPrint

def __ThreadIDPrint():
    msg = ''
    if not Debug_Setting.Thread_ID_Show:
        return msg
    thread_name = threading.currentThread().getName()
    if thread_name is None:
        thread_name = ''
    msg += '[Thread:%d\t' % threading._get_ident()
    if Debug_Setting.Thread_Name_Show:
        msg += '%s\t' % thread_name
    msg += ']\t'
    return msg
开发者ID:peterwyj,项目名称:WSDT,代码行数:12,代码来源:ALPSDebug.py


示例18: run

	def run(self):
		
		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 )
		
		while not self.__queue.empty():
			
			# NOTE: we have to check this here and not using the while to prevent the parser to be started on shutdown
			if not self.__running: break
			
			item = self.__queue.pop()
			
			splog('SP: Worker is processing')
			
			result = None
			
			try:
				result = item.identifier.getEpisode(
					item.name, item.begin, item.end, item.service
				)
			except Exception, e:
				splog("SP: Worker: Exception:", str(e))
				
				# Exception finish job with error
				result = str(e)
			
			config.plugins.seriesplugin.lookup_counter.value += 1
			
			if result and len(result) == 4:
				splog("SP: Worker: result callback")
				season, episode, title, series = result
				season = int(CompiledRegexpNonDecimal.sub('', season))
				episode = int(CompiledRegexpNonDecimal.sub('', episode))
				title = title.strip()
				if config.plugins.seriesplugin.replace_chars.value:
					repl = re.compile('['+config.plugins.seriesplugin.replace_chars.value.replace("\\", "\\\\\\\\")+']')
					
					splog("SP: refactor title", title)
					title = repl.sub('', title)
					splog("SP: refactor title", title)
					
					splog("SP: refactor series", series)
					series = repl.sub('', series)
					splog("SP: refactor series", series)
				self.__messages.push( (item.callback, (season, episode, title, series)) )
			else:
				splog("SP: Worker: result failed")
				self.__messages.push( (item.callback, result) )
			self.__pump.send(0)
开发者ID:Koernia,项目名称:e2openplugin-SeriesPlugin,代码行数:52,代码来源:SeriesPlugin.py


示例19: wrlock

 def wrlock(self, blocking=True):
     """
     Get a Write lock
     """
     me = _get_ident()
     with self.lock:
         while not self._wrlock(me):
             if not blocking:
                 return False
             self.nw += 1
             self.wcond.wait()
             self.nw -= 1
     return True
开发者ID:afoglia,项目名称:dyschord,代码行数:13,代码来源:readwritelock.py


示例20: acquire_thread

 def acquire_thread(self):
     """Run 'start_thread' listeners for the current thread.
     
     If the current thread has already been seen, any 'start_thread'
     listeners will not be run again.
     """
     thread_ident = threading._get_ident()
     if thread_ident not in self.threads:
         # We can't just use _get_ident as the thread ID
         # because some platforms reuse thread ID's.
         i = len(self.threads) + 1
         self.threads[thread_ident] = i
         self.bus.publish('start_thread', i)
开发者ID:fmcingvale,项目名称:cherrypy_gae,代码行数:13,代码来源:plugins.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python threading._sleep函数代码示例发布时间:2022-05-27
下一篇:
Python threadframe.dict函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap