Skip to content

Instantly share code, notes, and snippets.

View lsantosdemoura's full-sized avatar

Lucas Moura lsantosdemoura

View GitHub Profile
@lsantosdemoura
lsantosdemoura / get_first_return_from_parallel_functions.py
Created May 15, 2020 14:54
Running different functions in parallel and returning the first return
# adapted from:
# https://stackoverflow.com/questions/48677978/python-run-multiple-get-requests-in-parallel-and-stop-on-first-response
from multiprocessing import Queue, Process
from multiprocessing.queues import Empty
from time import sleep
def f1(queue):
print('f1')
def funcao_1(self, url):
scrapy.Request(url, callback=download_pdf)
return list(requests)
def parse(self, response):
retorno = funcao_1()
for r in retorno:
yield r
self.funcao_2()
self.funcao_3()