Download utils/parallel.py from cdcd2024/WaveLSFromer: direct link, hf CLI and curl.
- Browser
- Download file 746 Bytes
-
https://huggingface.co/cdcd2024/WaveLSFromer/resolve/main/utils/parallel.py
- Command line
-
hf download hf://cdcd2024/WaveLSFromer/utils/parallel.py
-
curl -L -o parallel.py https://huggingface.co/cdcd2024/WaveLSFromer/resolve/main/utils/parallel.py
746 Bytes
| import multiprocessing | |
| import multiprocessing.pool | |
| class NoDaemonProcess(multiprocessing.Process): | |
| """A process that can spawn other processes""" | |
| def daemon(self): | |
| return False | |
| def daemon(self, val): | |
| pass | |
| # We sub-class multiprocessing.pool.Pool instead of multiprocessing.Pool | |
| # because the latter is only a wrapper function, not a proper class. | |
| class NoDaemonProcessPool(multiprocessing.pool.Pool): | |
| """A multiprocessing pool whose processes can spawn other processes""" | |
| Process = NoDaemonProcess | |
| def Process(self, *args, **kwds): | |
| proc = super(NoDaemonProcessPool, self).Process(*args, **kwds) | |
| proc.__class__ = NoDaemonProcess | |
| return proc | |