I have this code that I am trying to make asynchronous
def m1():
links={
#my list of links
}
rs = (grequests.get(u) for u in links)
res = grequests.map(rs)
for r in res:
z = 0
soup = BeautifulSoup(r.text, 'lxml')
soupstr = str(soup)
if 'foo' in soupstr:
list = []
children = soup.find('div', class_='class')
childrens = children.findChildren()
for x in childrens:
y = x.get('value')
if y is None:
continue
list.append(y)
length = len(list)
if length == 0:
z = 0
elif z < length:
z = length
#rest of the script
while True:
m1()
But obviously that doesn't work because it makes z = 0 every loop. Any ideas?