This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import signal | |
class SignalExitter: | |
def __init__(self): | |
self.event = threading.Event() | |
signal.signal(signal.SIGINT, self._exit_by_signal) | |
signal.signal(signal.SIGTERM, self._exit_by_signal) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bfs( start, end, graph ): | |
todo = [(start, [start])] | |
while len( todo ): | |
node, path = todo.pop( 0 ) | |
for next_node in graph[node]: | |
if next_node in path: | |
continue | |
elif next_node == end: | |
yield path + [next_node] | |
else: |