本文整理汇总了Python中thread.join函数的典型用法代码示例。如果您正苦于以下问题:Python join函数的具体用法?Python join怎么用?Python join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了join函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_insert_balance
def test_insert_balance(self):
""" Test that insert into the runqueue of a remote thread does not affect the
bookkeeping of the current thread.
"""
thread, task = self.create_thread_task()
try:
task.remove()
before = stackless.getruncount()
task.insert()
after = stackless.getruncount()
# only the runnable count on the remote thread
# should change
self.assertEqual(before, after)
finally:
thread.join()
开发者ID:dev-alex-alex2006hw,项目名称:tools,代码行数:15,代码来源:test_thread.py
示例17: test_thread
def test_thread(names):
i.append(0)
j = 0
while len(names):
try:
if i[0] < th:
n = names.pop(0)
i[0] = i[0] + 1
thread = force(n, j)
thread.start()
j = j + 1
except KeyboardInterrupt:
print "Attack suspended by user..\n"
sys.exit()
thread.join()
开发者ID:obnosis,项目名称:QuickTools,代码行数:15,代码来源:brutessh.py
示例18: run
def run(self, timeout=0):
def target():
print 'Thread started'
self.process = subprocess.Popen(self.cmd, shell=True)
self.process.communicate()
print 'Thread finished'
thread = threading.Thread(target=target)
thread.start()
if timeout == 0:
return
thread.join(timeout)
if thread.is_alive():
print 'Terminating process'
self.process.terminate()
thread.join()
print self.process.returncode
开发者ID:randoms,项目名称:ipfs-data,代码行数:16,代码来源:ipdatafs.py
示例19: shutdown
def shutdown():
global go
go = None
print("Shutting down all threads...")
currentThread = threading.currentThread()
for thread in threading.enumerate():
if thread != currentThread:
thread.join()
print("All threads finished.")
if lcd != None:
print("Clearing LCD and turning it off...")
lcd.lcd_clear()
sleep(1)
lcd.backlight(0)
print("LCD backlight off.")
return
开发者ID:cmccandless,项目名称:WeatherPiLcd,代码行数:16,代码来源:weatherLcd.py
示例20: test_qpid_topic_and_fanout
def test_qpid_topic_and_fanout(self):
for receiver_id in range(self.no_receivers):
consumer = self.consumer_cls(self.qpid_conf,
self.session_receive,
self.receive_topic,
self.consumer_callback)
self._receivers.append(consumer)
# create receivers threads
thread = threading.Thread(target=self._try_receive_msg,
args=(receiver_id, self.no_msgs,))
self._receiver_threads.append(thread)
for sender_id in range(self.no_senders):
publisher = self.publisher_cls(self.qpid_conf,
self.session_send,
self.topic)
self._senders.append(publisher)
# create sender threads
thread = threading.Thread(target=self._try_send_msg,
args=(sender_id, self.no_msgs,))
self._sender_threads.append(thread)
for thread in self._receiver_threads:
thread.start()
for thread in self._sender_threads:
thread.start()
for thread in self._receiver_threads:
thread.join()
for thread in self._sender_threads:
thread.join()
# Each receiver should receive all the messages sent by
# the sender(s).
# So, Iterate through each of the receiver items in
# self._messages and compare with the expected messages
# messages.
self.assertEqual(len(self._expected), self.no_senders)
self.assertEqual(len(self._messages), self.no_receivers)
for key, messages in self._messages.iteritems():
self.assertEqual(self._expected, messages)
开发者ID:WaylandAce,项目名称:oslo.messaging,代码行数:47,代码来源:test_qpid.py
注:本文中的thread.join函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论