-
Notifications
You must be signed in to change notification settings - Fork 390
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
fix(python): respect concurrency in worker #2062
Conversation
python/bullmq/worker.py
Outdated
@@ -59,21 +59,19 @@ async def run(self): | |||
token_postfix = 0 | |||
|
|||
while not self.closed: | |||
if len(jobs) == 0 and len(self.processing) < self.opts.get("concurrency") and not self.closing: | |||
while len(self.processing) < self.opts.get("concurrency") and not self.closing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is a proper solution as this could result in multiple calls to BRPOPLPUSH instead of only 1, as we do on the typescript version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see it similar https://github.com/taskforcesh/bullmq/blob/master/src/classes/worker.ts#L395-L407 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the difference is the asyncQueue that avoids the excessive number of calls. It waits until BRPOPLPUSH has timedout or returned a job id. It is a bit tricky to understand the code, but that's the idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at the end, the magic is handled by waiting attribute in worker class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks correct to me.
fixes #2063