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

Raise error early when invalid arguments are provided to .apply_async #54

Closed
imranariffin opened this issue Jun 18, 2023 · 0 comments · Fixed by #62
Closed

Raise error early when invalid arguments are provided to .apply_async #54

imranariffin opened this issue Jun 18, 2023 · 0 comments · Fixed by #62
Assignees

Comments

@imranariffin
Copy link
Owner

Currently, we don't do any validation to the arguments provided, so we publish the tasks with the invalid argument and wait for the result. The result will never come because the worker fails to execute the task due to invalid argument.

We can reproduce this way:

import asyncio

import aiotaskq


@aiotaskq.task
def some_task(some_arg: int) -> int:
    return some_arg * 2


if __name__ == "__main__":
    asyncio.run(some_task.apply_async(some_INVALID_argument=2))
   # Never reach this line since no result will come

We need to raise error early like this:

InvalidArgumentError("Invalid argument was provided to `.apply_async`")
@imranariffin imranariffin self-assigned this Jul 17, 2023
imranariffin added a commit that referenced this issue Jul 18, 2023
* Run validation on the arguments using the `inspect.Signature.bind`
  built-in utility
* If invalid, raise error. Otherwise, proceed to sending task to queue
* This aims to help user identity bug early on
* We might consider turning this feature on only when AIOTASKQ_DEBUG=1 or
  something like that in the future
imranariffin added a commit that referenced this issue Jul 18, 2023
* Run validation on the arguments using the `inspect.Signature.bind`
  built-in utility
* If invalid, raise error. Otherwise, proceed to sending task to queue
* This aims to help user identity bug early on
* We might consider turning this feature on only when AIOTASKQ_DEBUG=1 or
  something like that in the future
imranariffin added a commit that referenced this issue Jul 18, 2023
* Run validation on the arguments using the `inspect.Signature.bind`
  built-in utility
* If invalid, raise error. Otherwise, proceed to sending task to queue
* This aims to help user identity bug early on
* We might consider turning this feature on only when AIOTASKQ_DEBUG=1 or
  something like that in the future

Bump version to 0.0.12
imranariffin added a commit that referenced this issue Jul 22, 2023
* Run validation on the arguments using the `inspect.Signature.bind`
  built-in utility
* If invalid, raise error. Otherwise, proceed to sending task to queue
* This aims to help user identity bug early on
* We might consider turning this feature on only when AIOTASKQ_DEBUG=1 or
  something like that in the future

Bump version to 0.0.12

Signed-off-by: Imran Ariffin <ariffin.imran@gmail.com>
imranariffin added a commit that referenced this issue Jul 22, 2023
* Run validation on the arguments using the `inspect.Signature.bind`
  built-in utility
* If invalid, raise error. Otherwise, proceed to sending task to queue
* This aims to help user identity bug early on
* We might consider turning this feature on only when AIOTASKQ_DEBUG=1 or
  something like that in the future

Bump version to 0.0.12

Signed-off-by: Imran Ariffin <ariffin.imran@gmail.com>
imranariffin added a commit that referenced this issue Jul 22, 2023
* Run validation on the arguments using the `inspect.Signature.bind`
  built-in utility
* If invalid, raise error. Otherwise, proceed to sending task to queue
* This aims to help user identity bug early on
* We might consider turning this feature on only when AIOTASKQ_DEBUG=1 or
  something like that in the future

Bump version to 0.0.12

Signed-off-by: Imran Ariffin <ariffin.imran@gmail.com>
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

Successfully merging a pull request may close this issue.

1 participant