Skip to content

Instantly share code, notes, and snippets.

View MrKich's full-sized avatar

Alexander MrKich

  • Russian/Saint-Petersburg
View GitHub Profile
@MrKich
MrKich / signal_exitter.py
Created May 23, 2018 11:55
Simple class for catching exit signals
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)
@MrKich
MrKich / bfs_python.py
Last active May 31, 2019 03:46
Python BFS
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: