Przeglądaj źródła

Add docstring for MPFuture.reset_state()

Aleksandr Borzunov 4 lat temu
rodzic
commit
c11f3fd773
2 zmienionych plików z 8 dodań i 1 usunięć
  1. 7 0
      hivemind/utils/mpfuture.py
  2. 1 1
      tests/conftest.py

+ 7 - 0
hivemind/utils/mpfuture.py

@@ -129,6 +129,13 @@ class MPFuture(base.Future, Generic[ResultType]):
 
     @classmethod
     def reset_backend(cls):
+        """
+        Reset the MPFuture backend. This is useful when the state may have been corrupted
+        (e.g. killing child processes may leave the locks acquired and the background thread blocked).
+
+        This method is neither thread-safe nor process-safe.
+        """
+
         cls._initialization_lock = mp.Lock()
         cls._update_lock = mp.Lock()
         cls._active_pid = None

+ 1 - 1
tests/conftest.py

@@ -28,5 +28,5 @@ def cleanup_children():
             with suppress(psutil.NoSuchProcess):
                 child.kill()
 
-    # Killing child processes may leave the global MPFuture state broken, so we reset it
+    # Killing child processes may leave the MPFuture backend broken
     MPFuture.reset_backend()