You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
First of all, I would like to thank you for writing such a versatile, powerful and yet easy to use library for working with concurrent data pipelines.
One of my office projects had an use case where I needed to make multiple independent post requests to a REST API with certain payloads. We chose pypeln module for making multiple concurrent requests. As we required API responses in the same order of the post requests, we tried using pypeln.task.ordered, but the received responses were not always in the same order as expected.
Therefore I experimented with the following piece of code:
import pypeln as pl
import asyncio
from random import random
async def slow_add1(x):
await asyncio.sleep(random())
return x+1
async def main():
data = range(20)
stage = pl.task.map(slow_add1, data, workers=1, maxsize=4)
stage = pl.task.ordered(stage)
out = await stage
print("Output: ", out)
for i in range(15):
print("At Iteration:",i)
asyncio.run(main())
I obsereved the results over multiple runs & found that the responses are not always in proper order.
One such sample output is:
Please notice that output for iteration 3 as well as 11 is out of order (others are OK).
Since I am a new user, I might be misunderstanding something here.
My doubt is that, doesn't pypeln.task.ordered ensures that the response received would be in same order as in request, irrespective of uneven/unequal processing time of requests? Am I missing something here ?
The text was updated successfully, but these errors were encountered:
Hi,
First of all, I would like to thank you for writing such a versatile, powerful and yet easy to use library for working with concurrent data pipelines.
One of my office projects had an use case where I needed to make multiple independent post requests to a REST API with certain payloads. We chose pypeln module for making multiple concurrent requests. As we required API responses in the same order of the post requests, we tried using pypeln.task.ordered, but the received responses were not always in the same order as expected.
Therefore I experimented with the following piece of code:
I obsereved the results over multiple runs & found that the responses are not always in proper order.
One such sample output is:
Please notice that output for iteration 3 as well as 11 is out of order (others are OK).
Since I am a new user, I might be misunderstanding something here.
My doubt is that, doesn't pypeln.task.ordered ensures that the response received would be in same order as in request, irrespective of uneven/unequal processing time of requests? Am I missing something here ?
The text was updated successfully, but these errors were encountered: