本文整理汇总了Python中ryu.lib.hub.kill函数的典型用法代码示例。如果您正苦于以下问题:Python kill函数的具体用法?Python kill怎么用?Python kill使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了kill函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ssl
def test_ssl(self):
"""Tests SSL server functionality."""
# TODO: TLS version enforcement is necessary to avoid
# vulnerable versions. Currently, this only tests TLS
# connectivity.
this_dir = os.path.dirname(sys.modules[__name__].__file__)
saved_exception = None
try:
ssl_version = ssl.PROTOCOL_TLS
except AttributeError:
# For compatibility with older pythons.
ssl_version = ssl.PROTOCOL_TLSv1
for i in range(3):
try:
# Try a few times as this can fail with EADDRINUSE
port = random.randint(5000, 10000)
server = hub.spawn(self._test_ssl, this_dir, port)
hub.sleep(1)
client = hub.StreamClient(("127.0.0.1", port),
timeout=5,
ssl_version=ssl_version)
if client.connect() is not None:
break
except Exception as e:
saved_exception = e
continue
finally:
try:
hub.kill(server)
except Exception:
pass
else:
self.fail("Failed to connect: " + str(saved_exception))
示例2: stop
def stop(self):
super(GaugeThreadPoller, self).stop()
self._running = False
if self.is_active():
hub.kill(self.thread)
hub.joinall([self.thread])
self.thread = None
示例3: close
def close(self):
if self.test_thread is not None:
hub.kill(self.test_thread)
if self.ingress_event:
self.ingress_event.set()
hub.joinall([self.test_thread])
self._test_end('--- Test terminated ---')
示例4: serve
def serve(self):
send_thr = hub.spawn(self._send_loop)
try:
self._recv_loop()
finally:
hub.kill(send_thr)
hub.joinall([send_thr])
示例5: set_querier_mode
def set_querier_mode(self, dpid, server_port):
"""set the datapath to work as a querier. note that you can set
up only the one querier. when you called this method several
times, only the last one becomes effective."""
self.dpid = dpid
self.server_port = server_port
if self._querier_thread:
hub.kill(self._querier_thread)
self._querier_thread = None
示例6: serve
def serve(self):
send_thr = hub.spawn(self._send_loop)
hello = self.oxproto_parser.OXPHello(self)
self.send_msg(hello)
try:
self._recv_loop()
finally:
hub.kill(send_thr)
hub.joinall([send_thr])
示例7: delete
def delete(self, pkt=None, del_addr=None):
if pkt is not None:
del_list = [pkt]
else:
assert del_addr is not None
del_list = [pkt for pkt in self if pkt.dst_ip in del_addr]
for pkt in del_list:
self.remove(pkt)
hub.kill(pkt.wait_thread)
pkt.wait_thread.wait()
示例8: serve
def serve(self):
send_thr = hub.spawn(self._send_loop)
# send hello message immediately
hello = self.ofproto_parser.OFPHello(self)
self.send_msg(hello)
try:
self._recv_loop()
finally:
hub.kill(send_thr)
hub.joinall([send_thr])
示例9: test_spawn_kill_die_joinall
def test_spawn_kill_die_joinall(self):
def _child(result):
result.append(1)
threads = []
result = []
with hub.Timeout(2):
threads.append(hub.spawn(_child, result))
threads.append(hub.spawn(_child, result))
hub.sleep(0.5)
for t in threads:
hub.kill(t)
hub.joinall(threads)
assert len(result) == 2
示例10: _remove_from_queue
def _remove_from_queue(self, rule_id):
queue_head = True
for time_period in self._rule_time_queue:
for item in time_period:
if item == rule_id:
time_period.remove(rule_id)
# Was this the only rule being scheduled
# at rule_id's time?
if len(time_period) < 1:
self._rule_time_queue.remove(time_period)
if queue_head:
hub.kill(self._gthread_rule_dist)
self._gthread_rule_dist = hub.spawn(self._distribute_rules_time)
return
queue_head = False
示例11: serve
def serve(self):
# TODO: entry point
send_thr = hub.spawn(self._send_loop)
# send hello message immediately
#hello = self.ofproto_parser.OFPHello(self)
#self.send_msg(hello)
buf = "Server"
self.socket.sendall(buf)
try:
self._recv_loop()
finally:
hub.kill(send_thr)
hub.joinall([send_thr])
示例12: stop
def stop(self):
# NOTE(jkoelker) Attempt to gracefully stop the accept loop
self.is_active = False
# NOTE(jkoelker) Forceably kill the loop and clear the main_thread
if self.main_thread:
hub.kill(self.main_thread)
self.main_thread = None
# NOTE(jkoelker) Stop all the clients
for c in self._clients.values():
c.stop()
# NOTE(jkoelker) super will only take care of the event and joining now
super(OVSDB, self).stop()
示例13: test_spawn_kill_nowait_joinall
def test_spawn_kill_nowait_joinall(self):
# XXX this test relies on the scheduling behaviour.
# the intention here is, killing threads before they get active.
def _child(result):
result.append(1)
threads = []
result = []
with hub.Timeout(2):
threads.append(hub.spawn(_child, result))
for t in threads:
hub.kill(t)
hub.joinall(threads)
assert len(result) == 0
示例14: test_spawn_kill_joinall
def test_spawn_kill_joinall(self):
def _child(ev2, result):
ev2.wait()
result.append(1)
ev2 = hub.Event()
threads = []
result = []
with hub.Timeout(2):
threads.append(hub.spawn(_child, ev2, result))
threads.append(hub.spawn(_child, ev2, result))
hub.sleep(0.5)
for t in threads:
hub.kill(t)
hub.joinall(threads)
assert len(result) == 0
示例15: serve
def serve(self):
send_thr = hub.spawn(self._send_loop)
# send hello message immediately
hello = self.ofproto_parser.OFPHello(self)
self.send_msg(hello)
echo_thr = hub.spawn(self._echo_request_loop)
try:
self._recv_loop()
finally:
hub.kill(send_thr)
hub.kill(echo_thr)
hub.joinall([send_thr, echo_thr])
self.is_active = False