uqfoundation / pathos

parallel graph management and execution in heterogeneous computing
http://pathos.rtfd.io
Other
1.38k stars 89 forks source link

How to mimic multiprocessing.Process #162

Closed TheCodeSummoner closed 5 years ago

TheCodeSummoner commented 5 years ago

Question:

How to recreate the following in pathos?

from multiprocessing import Process

def foo():
    while True:
        print("Foo-ing")

if __name__ == "__main__":
    Process(target=foo).start()

I am aware of multiprocess.dummy.Process, however, I am unsure if it's any different from threading.Thread as it derives from it, and I would like to run a process rather than a thread.

The application I am developing will be running multiple, distinct functionalities, so as far as I understand having a proper Process rather than a Thread is crucial. Does pathos provide a tool to run an infinite process like that?

mmckerns commented 5 years ago

Either of these should be what you want:

>>> import pathos
>>> pathos.helpers.mp.Process
<class 'multiprocess.process.Process'>
>>> import multiprocess as mp
>>> mp.Process is pathos.helpers.mp.Process
True
>>> 

Please close the issue if this answers your question.