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

Unexpected behaviour of .delay #10

Open
electronick1 opened this issue Oct 19, 2020 · 1 comment
Open

Unexpected behaviour of .delay #10

electronick1 opened this issue Oct 19, 2020 · 1 comment
Assignees

Comments

@electronick1
Copy link

electronick1 commented Oct 19, 2020

Before job added to the queue, we executing adv_bind_arguments here

If processor has **kwargs defined inside, all data will be lost and "Argument missing" error will be raised. This is example of adv_bind_arguments behaviour with **kwargs function:

from sqs_workers.utils import adv_bind_arguments

def wrapper_func(*args, **kwargs):
     def func(a):
           print(a)
     func(*args, **kwargs)
     print(args, kwargs)

adv_bind_arguments(wrapper_func, [], dict(a=1))
# pring result: {'args': (), 'kwargs': {}}

As you can see a=1 is lost and "Argument missing" error will be raise when processor will try to execute this job.
This is especially critical when you want to decorate your sqs processor, because you should have *args, **kwargs statement inside a decorator.

@imankulov
Copy link
Contributor

I can confirm that the problem exists, but there's no easy way to fix it quickly without rewriting Werkzeug's bind_arguments:

>>> from werkzeug.utils import bind_arguments
>>> def foo(a, b): pass
...
>>> bind_arguments(foo, (), {"a": 1, "b": 2})
{'a': 1, 'b': 2}
>>> def foo_kwargs(**kwargs): pass
...
>>> bind_arguments(foo_kwargs, (), {"a": 1, "b": 2})
{'kwargs': {}}

As you can see, the output for the function that accepts kwargs doesn't make any sense.

Patches or documentation updates with a workaround are welcome

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

3 participants