Skip to content

Instantly share code, notes, and snippets.

@rsperl
Last active July 25, 2022 16:07
Show Gist options
  • Save rsperl/5e8ab5f78484ec54550d92bcf6adfc09 to your computer and use it in GitHub Desktop.
Save rsperl/5e8ab5f78484ec54550d92bcf6adfc09 to your computer and use it in GitHub Desktop.
multiprocessing #python #snippet
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