Closed msopko81 closed 2 years ago
I guess just using the code rather than the class name should fix this, yes?
So, since the code
is a user-provided string and users may have production code running that puts characters in that string that cannot exist in a filename, I vote to combine the __module__
property of the CronJob class with the __name__
property.
Old (cron_class.__name__
): CronJob
New ('.'.join(cron_class.__module__, cron_class.__name__)
): my_app_name.cron.CronJob
This could be implemented in the base class to avoid the same issue with the file-based locking backend.
If someone can get back to me and tell me if this makes sense I'll submit a PR.
When setting the lock for the cron job, the cron class name is used instead of the code. The code should be a unique code as should be used instead of the class name. False positive locking errors can occur if 2 crons have the same cron class name, but are different. For example, app1.crons.ProcessInvoice and app2.crons.ProcessInvoice. If these crons are scheduled at the same time, then only 1 will run and the other will say that a lock was found since the lock key will be ProcessInvoice.