Fix Typos, Warn on Unmatching Brokers#423
Conversation
|
Yooooo. That's really bad. Sorry for not thinking of this case. I should have created this warning earlier. This PR is amazing. Thanks for making it! |
s3rius
left a comment
There was a problem hiding this comment.
These changes should fix the error.
Co-authored-by: Pavel Kirilin <s3riussan@gmail.com>
Co-authored-by: Pavel Kirilin <s3riussan@gmail.com>
|
Please run |
|
There are some weird things going on, where certain linters break the syntax and cause subsequent linters to fail 😬 Specifically it looks like add_trailing_commas is adding them in unwanted places and creating invalid python syntax |
taskiq/abc/broker.py
Outdated
| :param task: Decorated task. | ||
| """ | ||
| if task.broker != self: | ||
| raise TaskRejectedError( |
There was a problem hiding this comment.
It's not a syntax error. It's izulu. We use it for errors.
Please define separate error class for this error with
__template__ and broker argument.
|
Okay. Actually this PR is fine by me. So, I'm gonna merge it an fix on the main branch. |
* fix typos * warn if task broker doesn't match self * oopsie * Update taskiq/schedule_sources/label_based.py Co-authored-by: Pavel Kirilin <s3riussan@gmail.com> * Update taskiq/schedule_sources/label_based.py Co-authored-by: Pavel Kirilin <s3riussan@gmail.com> * raise error on broker mismatch * ruffed * create new error class --------- Co-authored-by: Pavel Kirilin <s3riussan@gmail.com>
* fix typos * warn if task broker doesn't match self * oopsie * Update taskiq/schedule_sources/label_based.py Co-authored-by: Pavel Kirilin <s3riussan@gmail.com> * Update taskiq/schedule_sources/label_based.py Co-authored-by: Pavel Kirilin <s3riussan@gmail.com> * raise error on broker mismatch * ruffed * create new error class --------- Co-authored-by: Pavel Kirilin <s3riussan@gmail.com>


Hi all, thanks for making this repo; it's really useful.
This PR fixes some typos and also adds a warning when a scheduled task's broker doesn't match the broker it's being executed on. This has fucked me over several times when scheduled tasks are registered but silently fail to execute. This was my own fault since I was double-registering tasks. But it's a nasty pitfall.
Should we detect mismatched brokers a bit sooner, i.e. when the task is first registered? Probably if a user tries to register a function that's already an instance of a decorated task, we should throw an error if the brokers don't match.