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


Python thread.join函数代码示例

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


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

示例1: __createSeries

  def __createSeries(self, seasonType, seasonLink):
    firstSeason = TVCriticInfo(seasonType, seasonLink)
    self.series.append(firstSeason)

    soup = firstSeason.page

    soup = soup.find('li', {'class': 'summary_detail product_seasons'})

    seasonData = soup.find('span', {'class': 'data'})

    seasonLinks = seasonData.find_all('a')

    self.__getTitle(firstSeason.title)

    for link in seasonLinks:
      link = BASE_URL+link['href']
      mythread = threading.Thread(target = self.__updateSeries,
        args = (seasonType, link))
      mythread.start()
    
    for thread in threading.enumerate():
      if thread is not threading.currentThread():
        thread.join()
        
    return self.__sortSeries()
开发者ID:khangsile,项目名称:metacritic_api,代码行数:25,代码来源:metacritic.py

示例2: checkTimeOutPut

def checkTimeOutPut(args):
    t = None
    global currCommandProcess
    global stde
    global stdo
    stde = None
    stdo = None
    def executeCommand():
        global currCommandProcess
        global stdo
        global stde
        try:
            stdo, stde = currCommandProcess.communicate()
            printLog('stdout:\n'+str(stdo))
            printLog('stderr:\n'+str(stde))
        except:
            printLog("ERROR: UNKNOWN Exception - +checkWinTimeOutPut()::executeCommand()")

    currCommandProcess = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True)
    thread = Thread(target=executeCommand)
    thread.start()
    thread.join(TIMOUT_VAL) #wait for the thread to complete 
    if thread.is_alive():
        printLog('ERROR: Killing the process - terminating thread because it is taking too much of time to execute')
        currCommandProcess.kill()
        printLog('ERROR: Timed out exception')
        raise errorHandler.ApplicationException(__file__, errorHandler.TIME_OUT)
    if stdo == "" or stdo==None:
        errCode = currCommandProcess.poll()
        printLog('ERROR: @@@@@Raising Called processor exception')
        raise subprocess.CalledProcessError(errCode, args, output=stde)
    return stdo
开发者ID:amirgholami,项目名称:inplace,代码行数:32,代码来源:measurePerformance.py

示例3: calculateAverage

def calculateAverage(period, classname):
    now = datetime.datetime.utcnow().replace(tzinfo=utc)
    round_now = now - datetime.timedelta(seconds=now.second, microseconds=now.microsecond)
    for server in Server.objects.all().select_related():
        try:
            threads = []
            for probe in server.probes.exclude(graph_type__name__in=['text']):
                thread = threading.Thread(target=calculateAveragesForPeriod, args=[period, classname, server, probe], name="SkwisshAverage.%s.%s" % (classname.__name__, probe.display_name.encode('utf-8').replace(" ", "_")))
                thread.setDaemon(False)
                thread.start()
                threads.append(thread)

            for thread in threads:
                thread.join()

            end = datetime.datetime.utcnow().replace(tzinfo=utc)
            total_time = end - now
            duration = float(int((total_time.seconds * 1000000) + total_time.microseconds) / 1000000.0)
            success = True
            message = "Calculated averages values for last %d minutes (server %s)" % (period, server.hostname)
        except:
            success = False
            message = traceback.format_exc()

        CronLog.objects.create(timestamp=round_now, action="average %dmin" % period, server=server, success=success, duration=duration, message=message)
开发者ID:cheekybastard,项目名称:django-skwissh,代码行数:25,代码来源:cron.py

示例4: testFoo

 def testFoo(self):
     def foo(): pass
     t, thread = GetRemoteTasklet(foo, ())
     try:
         t.run()
     finally:
         thread.join(2)
开发者ID:dev-alex-alex2006hw,项目名称:tools,代码行数:7,代码来源:test_thread.py

示例5: __init__

	def __init__(self):
		queue = Queue.Queue() # for return value from thread
		lock = threading.Lock()
		counter=0
		global archive
		archive = zipfile.ZipFile(args.file)
		archive.setpassword(args.password)
		fileList = []
		if (args.logfile):
			fileList=archive.namelist()
			self.writeObject(fileList,args.logfile)
		else:
			fileList=self.readObject(args.savedLogfile)
			args.logfile=args.savedLogfile# for simplicity later on


		threadList=[]
		for a in range (args.thread):
			t = threading.Thread(target=self.looper, args=(archive,fileList, queue))
			t.start()
			threadList.append(t)

		for thread in threadList:
			thread.join()
		self.writeObject(queue.get(),args.logfile)
开发者ID:Tomasuh,项目名称:various,代码行数:25,代码来源:smartzip.py

示例6: getListJoinThreadx

def getListJoinThreadx(parent, queue):
	categoryList = []
	for thread in queue:
		thread.join()
		if thread.response is not None:
			categoryList.extend(getCategoryPartLists(parent, thread.response))
			thread.response = None
	return categoryList
开发者ID:kratark,项目名称:ebay,代码行数:8,代码来源:categories.py

示例7: testInsert

 def testInsert(self):
     def foo():
         self.events.append(0)
     t, thread = GetRemoteTasklet(foo, ())
     try:
         t.insert()
     finally:
         thread.join(2)
     self.assertEqual(self.events, list(range(len(self.events))))
开发者ID:dev-alex-alex2006hw,项目名称:tools,代码行数:9,代码来源:test_thread.py

示例8: _cancel_all_threads

 def _cancel_all_threads(self):
     for thread, event in self._threads:
         SetEvent(event)
         try:
             thread.join()
         except RuntimeError:
             pass
         CloseHandle(event)
     self._threads = []
开发者ID:caetanus,项目名称:windows-file-changes-notify,代码行数:9,代码来源:win32_objects.py

示例9: join

    def join(self):
        """Stop processing work, and shut down the threads."""

        # Add the sentinels
        for thread in self.threads:
            self.ready_queue.put(None)

        for thread in self.threads:
            thread.join()
开发者ID:makeittotop,项目名称:py_queue,代码行数:9,代码来源:pool.py

示例10: __call__

 def __call__(self, * args, ** kwArgs):
   thread = TimeoutHelperThread(self._func, args, kwArgs, name = self._name)
   thread.start()
   thread.join(self._timeout)
   if thread.isAlive():
     raise chakana.error.Timeout(thread, self._timeout)
   if thread.error is None:
     return thread.result
   raise chakana.error.ChildException(thread.error, thread.exc_info)
开发者ID:EDAyele,项目名称:ptunes,代码行数:9,代码来源:threads.py

示例11: stop_all_threads

 def stop_all_threads(self, block=False):
     """
     Stops all threads. If block is True then actually wait for the thread
     to finish (may block the UI)
     """
     for thread in self.fooThreads.values():
         thread.cancel()
         if block:
             if thread.isAlive():
                 thread.join()
开发者ID:smolleyes,项目名称:gmediafinder-gtk3,代码行数:10,代码来源:gmediafinder.py

示例12: start_processing

def start_processing(url_list,key,email):
	for url in url_list:
		if len(url)<3:
			url_list.remove(url)
		else:
			thread=urlFetch(url,key)
			thread.start()
			if email:
				thread.join()
	if email:
		sendEmail(email,key)
开发者ID:souravpaul,项目名称:django-url-fetch,代码行数:11,代码来源:views.py

示例13: refreshpeerfileslooper

	def refreshpeerfileslooper(self):
		while(True):
			#for each peer in the database, get the file listing, which stores in db. When done, update screen.
			for i in range(len(self.database.getAllPeers())):
				thread = Thread(target=self.peerclient.getPeerListing, args=(self.database.getAllPeers()[i][0],))
				thread.start()
			try:
				thread.join()
			except:
				pass
			self.refreshCurrent()
			time.sleep(15)
开发者ID:travcunn,项目名称:Monkey-Share,代码行数:12,代码来源:monkeyshare.py

示例14: serve_forever_child

 def serve_forever_child( self ):
     # self.thread_pool = ThreadPool( self.nworkers, "ThreadPoolServer on %s:%d" % self.server_address )
     self.workers = []
     for i in range( self.nworkers ):
         worker = threading.Thread( target=self.serve_forever_thread )
         worker.start()
         self.workers.append( worker )
     self.time_to_terminate.wait()
     print "Terminating"
     for thread in self.workers:
         thread.join()
     self.socket.close()
开发者ID:dbcls,项目名称:dbcls-galaxy,代码行数:12,代码来源:fork_server.py

示例15: run

    def run(self, timeout):
        print "running " + self.cmd
        def target():
            self.process = subprocess.Popen(self.cmd, shell=True)
            self.process.communicate()

        thread = threading.Thread(target=target)
        thread.start()

        thread.join(timeout)
        if thread.is_alive():
            print 'Terminating process'
            self.process.terminate()
            thread.join()
开发者ID:Kadajett,项目名称:wearscript,代码行数:14,代码来源:monitor.py


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