diff --git a/multtest.py b/multtest.py new file mode 100644 index 000000000..91f748a64 --- /dev/null +++ b/multtest.py @@ -0,0 +1,14 @@ +import multiprocessing + + +def worker(a): + print(a) + + +if __name__ == "__main__": + a = [] + multiprocessing.set_start_method("spawn") + p = multiprocessing.Process(target=worker, args=("hello",)) + p.start() + a.append(p) + p.join() diff --git a/robyn/processpool.py b/robyn/processpool.py index 6e0042d58..03fde85ef 100644 --- a/robyn/processpool.py +++ b/robyn/processpool.py @@ -1,6 +1,7 @@ import asyncio import webbrowser from multiprocess import Process +import multiprocess as mp import signal import sys from typing import Dict, List @@ -77,6 +78,8 @@ def init_processpool( response_headers: Headers, ) -> List[Process]: process_pool = [] + ctx = mp.get_context("fork") + if sys.platform.startswith("win32"): spawn_process( directories, @@ -95,7 +98,7 @@ def init_processpool( for _ in range(processes): copied_socket = socket.try_clone() - process = Process( + process = ctx.Process( target=spawn_process, args=( directories,