pybind11
pybind11 copied to clipboard
Multiprocessing spawn processes with the same __name__
I have a code that use the multiprocessing module to spawn new processes like this:
...
ctx = multiprocessing.get_context('spawn')
process = ctx.Process(target=_worker, args=args, daemon=True)
process.start()
...
I have to distinguish them from the main execution, through the code:
if __name__ == '__main__':
...
If I run this script from command line (running Python.exe), the __name__ is different for each process. When I run it through the py::exec, the __name__ is always __main__. How can I overcome this issue? Thanks.