Skip to content

Instantly share code, notes, and snippets.

@EwertonBello
Last active May 7, 2020 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EwertonBello/6cc93a3db95025660ad1c38387436f4d to your computer and use it in GitHub Desktop.
Save EwertonBello/6cc93a3db95025660ad1c38387436f4d to your computer and use it in GitHub Desktop.
exemplo simples de multiprocessing com Process
import time
from multiprocessing import Process
def tarefa(seg):
time.sleep(seg)
print(f'Concluído em {seg} segundos...')
def main():
p1 = Process(target=tarefa, args=(4,))
p1.start()
p2 = Process(target=tarefa, args=(2,))
p2.start()
p3 = Process(target=tarefa, args=(3,))
p3.start()
p1.join()
p2.join()
p3.join()
print('Concluído!')
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment