Upload edit\Qwen3-TTS-test\.venv\Lib\site-packages\torch\multiprocessing\_atfork.py with huggingface_hub
Browse files
edit//Qwen3-TTS-test//.venv//Lib//site-packages//torch//multiprocessing//_atfork.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
__all__ = ["register_after_fork"]
|
| 6 |
+
|
| 7 |
+
if sys.platform == "win32":
|
| 8 |
+
import multiprocessing.util as _util
|
| 9 |
+
|
| 10 |
+
def _register(func):
|
| 11 |
+
def wrapper(arg):
|
| 12 |
+
func()
|
| 13 |
+
|
| 14 |
+
_util.register_after_fork(_register, wrapper)
|
| 15 |
+
|
| 16 |
+
else:
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
def _register(func):
|
| 20 |
+
os.register_at_fork(after_in_child=func)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def register_after_fork(func):
|
| 24 |
+
"""Register a callable to be executed in the child process after a fork.
|
| 25 |
+
|
| 26 |
+
Note:
|
| 27 |
+
In python < 3.7 this will only work with processes created using the
|
| 28 |
+
``multiprocessing`` module. In python >= 3.7 it also works with
|
| 29 |
+
``os.fork()``.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
func (function): Function taking no arguments to be called in the child after fork
|
| 33 |
+
|
| 34 |
+
"""
|
| 35 |
+
_register(func)
|