Issue
The code has 5 workers working. Every worker is like this (short code):
async def worker(name):
queue_item = await queue.get()
msg = queue_item.message #<--- first attempt
#.....#
try:
#...get_message fails(timeout)...raise#
except errors.TimedOutError:
#Retry to get the message
msg = await get_messages(queue_item.channel, ids=queue_item.id) # <-- retry
#in order to process it again I put it in different queue
await queue_retry.put(msg)
but,
Does the await queue_retry
wait for msg = await get_messages
to complete before to update the queue?
If it doesn't, I don't know what msg It'll put in, I suspect that it doesn't wait for the new get_message
and it'll put the the old one.
Solution
Does the
await queue_retry
wait formsg = await get_messages
to complete before to update the queue?
Yes: await get_messages(...)
does wait for get_messages(...)
to complete before proceeding. If you're not sure, change the variable name to emg msg2
(in both await
and queue_retry.put lines
) to convince yourself that you're not dealing with the old msg
.
Answered By - user4815162342
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.