Open komuw opened 5 years ago
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') {}
>>>
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.
this is the way celery does it; https://github.com/celery/celery/blob/e2161783e1a4cb021cd37d5df8581f7729f9095c/celery/app/trace.py#L439-L446
I think, we'll leave it as is for now.
I'm labelling this as a bug since it might be surprising for people using wiji
.
Currently, if we have a chained task, we use the return_value of the parent to queue the child: https://github.com/komuw/wiji/blob/e9da8eff13e08dfc53acad95c4a7642dad994881/wiji/worker.py#L183-L186
However, what happens if
return_value
is a tuple?I think in that case, we ought to;
ie only if
return_value
is a tuple