本文整理汇总了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()
示例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
示例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)
示例4: testFoo
def testFoo(self):
def foo(): pass
t, thread = GetRemoteTasklet(foo, ())
try:
t.run()
finally:
thread.join(2)
示例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)
示例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
示例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))))
示例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 = []
示例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()
示例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)
示例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()
示例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)
示例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)
示例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()
示例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()