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

Task cancelation from middlewares or dependencies. #133

Open
s3rius opened this issue May 15, 2023 · 11 comments
Open

Task cancelation from middlewares or dependencies. #133

s3rius opened this issue May 15, 2023 · 11 comments

Comments

@s3rius
Copy link
Member

s3rius commented May 15, 2023

We need to provide more control over task execution.

Currently we need to add Cancel error, to be able to implement scenario, described in #132.

@Sobes76rus
Copy link
Contributor

I created a PR #128, which can be described as a non-blocking sleep.
Can this be useful in the above scenario?

@Sobes76rus
Copy link
Contributor

Actually, i believe in their case it will be better to implement broker with custom listen method

@s3rius
Copy link
Member Author

s3rius commented May 15, 2023

@Sobes76rus Maybe. But what would listen be doing in that case?

I guess, it's not a broker-related thing, because it's an application logic. Because for some tasks, you may don't want to have rate limiting.

@Sobes76rus
Copy link
Contributor

We can listen multiple queues in broker
And limit some of them

@Sobes76rus
Copy link
Contributor

I mean, in that case rate-limited tasks should be in different queue

@s3rius
Copy link
Member Author

s3rius commented May 15, 2023

I guess it's overcomplicated. Because, what if you need to have different limits for 50 different tasks? You need to listen to 50 different queues then? In my opinion this problem might be solved in a more simple way, by giving you ability to cancel task execution from middleware or dependency. And send it again in the queue.

You can get access to broker message in context, and you can kick directly with broker. After the task is sent, you may cancel current, so it's not going to be written in result backend.

@Sobes76rus
Copy link
Contributor

Then it should be related to Retry not to Cancel

@s3rius
Copy link
Member Author

s3rius commented May 15, 2023

Good point. Yes. Maybe we need to do it with state manager, then.

@Sobes76rus
Copy link
Contributor

I would like to have a feature like NoResult,
It can be implemented using exceptions provided in TaskResult, when we implement exceptions serialization feature

@Sobes76rus
Copy link
Contributor

Like in Celery RejectError and RetryError exceptions

@s3rius
Copy link
Member Author

s3rius commented May 18, 2023

I guess now you can use #137 to simulate this behavior. The only thing we need to add is to set custom task-id to kicker.

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

2 participants