ソースを参照

Make DecentralizedAverager resistant to KeyboardInterrupt (#530)

(cherry picked from commit 19aa9665e0398a0bdcfaf2f842bbf71590950a51)
Ian McKenzie 2 年 前
コミット
071aad494b
1 ファイル変更2 行追加0 行削除
  1. 2 0
      hivemind/averaging/averager.py

+ 2 - 0
hivemind/averaging/averager.py

@@ -8,6 +8,7 @@ import ctypes
 import multiprocessing as mp
 import os
 import random
+import signal
 import threading
 import weakref
 from dataclasses import asdict
@@ -329,6 +330,7 @@ class DecentralizedAverager(mp.Process, ServicerBase):
         Starts averager in a background process. if await_ready, this method will wait until background dht
         is ready to process incoming requests or for :timeout: seconds max.
         """
+        signal.signal(signal.SIGINT, signal.SIG_IGN)
         self.start()
         if await_ready:
             self.wait_until_ready(timeout)