瀏覽代碼

clarify network shutdown

justheuristic 5 年之前
父節點
當前提交
7fe3b8d7a5
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      tesseract/network/__init__.py

+ 4 - 2
tesseract/network/__init__.py

@@ -36,8 +36,10 @@ class TesseractNetwork(mp.Process):
 
     def shutdown(self) -> None:
         """ Shuts down the network process """
-        warnings.warn("TODO shutdown network gracefully")
-        self.terminate()
+        if self.is_alive():
+            self.terminate()
+        else:
+            warnings.warn("Network shutdown has no effect: network process is already not alive")
 
     def get_experts(self, uids: List[str], heartbeat_expiration=HEARTBEAT_EXPIRATION) -> List[Optional[RemoteExpert]]:
         """ Find experts across DHT using their ids; Return a list of [RemoteExpert if found else None]"""