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

Fix concurrency issue in BackgroundJob #191

Merged
merged 1 commit into from
Apr 15, 2020

Conversation

davidor
Copy link
Contributor

@davidor davidor commented Apr 14, 2020

This PR replaces the usage of a class variable in BackgroundJob.

That class variable causes problems when using the async mode because fibers can modify it while others still need to read it. Luckily, with the current code, the only attribute affected is "enqueue_time", which is not accurate anyway (see #18).

Even without taking the async mode into consideration using a class var is counter-intuitive. The arguments of a particular job (service ID, app ID, etc.) should belong to an instance, they shouldn't be stored in a class var.

This causes problems when using the async mode because all the fibers
share that @Args class var. Luckily, with the current code, the only
attribute affected is "enqueue_time", which is not
accurate anyway (see #18).

Even without taking the async mode into consideration using a class var
is counter-intuitive. The arguments of a particular job (service ID, app
ID, etc.) should belong to an instance, they shouldn't be stored in a class var.
@davidor davidor requested a review from unleashed April 14, 2020 07:40
Copy link
Contributor

@unleashed unleashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok. You probably did this already, but let's make sure there are no users referencing @args elsewhere in other jobs inheriting from this code.

@davidor
Copy link
Contributor Author

davidor commented Apr 15, 2020

Yes, I checked. I didn't see any other usages of @args.

@davidor davidor merged commit e3c5bd2 into master Apr 15, 2020
@bors bors bot deleted the avoid-class-var-background-job branch April 15, 2020 16:19
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 this pull request may close these issues.

2 participants