Last active
July 25, 2022 16:07
-
-
Save rsperl/5e8ab5f78484ec54550d92bcf6adfc09 to your computer and use it in GitHub Desktop.
multiprocessing #python #snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Process | |
def method_to_call(*args, **kwargs): | |
# do what you do | |
pass | |
def main(): | |
# | |
rows = ("job1", "job2") | |
procs = [] | |
for jobname in rows: | |
p = Process( | |
name=jobname, | |
target=method_to_call, | |
args=("a", "b"), | |
kwargs=dict(arg1="val1", arg2="val2") | |
) | |
procs.append(p) | |
p.start() | |
# wait until all processes have finished | |
for p in procs: | |
p.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment