RapidTech1898R
Apify & Crawlee9mo ago
5 replies
RapidTech1898

Not working on all elements in the request_queue?

Hello - i try to run the following apify-code and as you can see in my example code below i would like to create a queue with 6 elements / combinations:

[('electrician', 'Southampton,England,United Kingdom'), ('electrician', 'Luton,England,United Kingdom'), ('electrician', 'Portsmouth,England,United Kingdom'), ('accountant', 'Southampton,England,United Kingdom'), ('accountant', 'Luton,England,United Kingdom'), ('accountant', 'Portsmouth,England,United Kingdom')]

But when i run the code only the first element is executed from the queue and then the actor is exiting:

[apify] INFO [Status message]: Starting actor...
[apify] INFO [('electrician', 'Southampton,England,United Kingdom'), ('electrician', 'Luton,England,United Kingdom'), ('electrician', 'Portsmouth,England,United Kingdom'), ('accountant', 'Southampton,England,United Kingdom'), ('accountant', 'Luton,England,United Kingdom'), ('accountant', 'Portsmouth,England,United Kingdom')]
[apify] INFO 6
return self.serializer.to_python(
[apify] INFO Working for electrician in Southampton,England,United Kingdom
[apify] INFO [Status message]: Actor finished...
[apify] INFO Exiting Actor ({"exit_code": 0})
['electrician', 'Southampton,England,United Kingdom', 'Cablefrog Electrical']

This is the way i build the queue:
...
inpCombinations = list(itertools.product(inpSearchWords, inpSearchLoc))
Actor.log.info(inpCombinations)
Actor.log.info(len(inpCombinations))
baseLink = "https://www.bing.com/maps"
request_queue = await Actor.open_request_queue()
for i,e in enumerate(inpCombinations):
newReq = Request.from_url(f"{baseLink}#{i}")
newReq.user_data = {"search": list(e)}
await request_queue.add_request(newReq)
...

And thats the way i try to run trough it:
...
while request := await request_queue.fetch_next_request():
....
Was this page helpful?