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

parent of chained task returning tuple #29

Open
komuw opened this issue Mar 18, 2019 · 5 comments
Open

parent of chained task returning tuple #29

komuw opened this issue Mar 18, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@komuw
Copy link
Owner

komuw commented Mar 18, 2019

Currently, if we have a chained task, we use the return_value of the parent to queue the child:

wiji/wiji/worker.py

Lines 183 to 186 in e9da8ef

return_value = await self.the_task.run(*task_args, **task_kwargs)
if self.the_task.chain:
# enqueue the chained task using the return_value
await self.the_task.chain.delay(return_value)

However, what happens if return_value is a tuple?
I think in that case, we ought to;

await self.the_task.chain.delay(*return_value)

ie only if return_value is a tuple

@komuw
Copy link
Owner Author

komuw commented Mar 18, 2019

def cool():
    return 34, "name"

def run(*args, **kwargs):
    print(args, kwargs)

return_value = cool()

## what we are currently doing
>>> run(return_value)
((34, 'name'),) {}

## versus what I think we ought to do
>>> run(*return_value)
(34, 'name') {}
>>>

@komuw
Copy link
Owner Author

komuw commented Mar 18, 2019

however, think of situation where:

import typing
def run(value: typing.Tuple, **kwargs):
    print(value, kwargs)

ie, run expects a tuple as it's first argument.

in such a case

## what we are currently doing
>>> run(return_value)
(34, 'name') {}

## versus what I think we ought to do
>>> run(*return_value)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: run() takes 1 positional argument but 2 were given

so we haven't made the situation any better.

@komuw
Copy link
Owner Author

komuw commented Mar 18, 2019

@komuw
Copy link
Owner Author

komuw commented Mar 18, 2019

I think, we'll leave it as is for now.

@komuw komuw added the bug Something isn't working label May 23, 2019
@komuw
Copy link
Owner Author

komuw commented May 23, 2019

I'm labelling this as a bug since it might be surprising for people using wiji.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant