Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ordered in pypeln.task is not always ordered #56

Closed
nav181 opened this issue Oct 4, 2020 · 3 comments
Closed

ordered in pypeln.task is not always ordered #56

nav181 opened this issue Oct 4, 2020 · 3 comments

Comments

@nav181
Copy link

nav181 commented Oct 4, 2020

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:

Issue_LI
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 ?

@cgarciae
Copy link
Owner

cgarciae commented Oct 4, 2020

Hey! Thanks for reporting. I can confirm this is a bug, will try to fix it soon.

@cgarciae
Copy link
Owner

cgarciae commented Oct 4, 2020

Fixed in version 0.4.5, please update :)

@cgarciae cgarciae closed this as completed Oct 5, 2020
@nav181
Copy link
Author

nav181 commented Oct 5, 2020

Fixed in version 0.4.5, please update :)

Thanks @cgarciae for such a prompt solution to the problem. Now it's working as expected :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants