mirror of
https://github.com/simon987/chan_feed.git
synced 2025-04-20 02:26:44 +00:00
Gracefully handle sigint
This commit is contained in:
parent
2aefd2c3a2
commit
7ea1612b32
12
run.py
12
run.py
@ -153,6 +153,8 @@ def publish_worker(queue: Queue, helper, p):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
item, board = queue.get()
|
item, board = queue.get()
|
||||||
|
if item is None:
|
||||||
|
break
|
||||||
publish(item, board, helper, channel, web)
|
publish(item, board, helper, channel, web)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -243,9 +245,15 @@ if __name__ == "__main__":
|
|||||||
publish_q = Queue()
|
publish_q = Queue()
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
publish_thread = Thread(target=publish_worker, args=(publish_q, chan_helper, proxy))
|
publish_thread = Thread(target=publish_worker, args=(publish_q, chan_helper, proxy))
|
||||||
|
publish_thread.setDaemon(True)
|
||||||
publish_thread.start()
|
publish_thread.start()
|
||||||
|
|
||||||
s = ChanScanner(chan_helper, proxy)
|
s = ChanScanner(chan_helper, proxy)
|
||||||
while True:
|
while True:
|
||||||
for p, b in s.all_posts():
|
try:
|
||||||
publish_q.put((p, b))
|
for p, b in s.all_posts():
|
||||||
|
publish_q.put((p, b))
|
||||||
|
except KeyboardInterrupt as e:
|
||||||
|
for _ in range(5):
|
||||||
|
publish_q.put((None, None))
|
||||||
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user