本文整理汇总了Python中threading.Thread.kill方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.kill方法的具体用法?Python Thread.kill怎么用?Python Thread.kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Thread
的用法示例。
在下文中一共展示了Thread.kill方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import kill [as 别名]
class CacheManager:
def __init__(self, fn, port):
self.fn = fn
self.server = None
self.t = None
self.port = port
def _reload_cache(self):
self.fn()
def _loop(self):
self.server = socket()
self.server.bind(('localhost', self.port))
self.server.listen(1)
while 1:
connection, address = self.server.accept()
value = connection.recv(32)
if value.strip() == 'clear':
self._reload_cache()
connection.send('cleared')
connection.close()
def run(self):
self.t = Thread(target=self._loop)
self.t.start()
def kill(self):
if self.server:
self.server.close()
if self.t:
self.t.kill()
示例2: Thread
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import kill [as 别名]
s.sendall(random_no+" "+str(len(random_no)))
a=''
some=''
after=time.time()
print "communication delay : %f" % (after-before)
s.close()
#create threads for different controllers
thread1 = Thread(target = conn_c1)
thread2 = Thread(target = conn_c2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
sleep(20)
thread = Thread(target = threaded_function)
thread.kill=1
thread.start()
#thread.join()
CLI( net )
thread.kill=0
thread.join()
print "*** Stopping network"
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' ) # for CLI output
multiControllerNet()