-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task lock should be non-local (#333)
Analyzing the thread safety of the heartbeat function in the sync executor: - Redis-py should by threadsafe by default unless `single_connection_client` is given, which is false by default. - When doing a `heartbeat()` we update the task timestamp, renew any task locks and any queue lock. - The queue lock ([`Semaphore`](https://github.com/closeio/tasktiger/blob/master/tasktiger/redis_semaphore.py)) does not care about threads so we can therefore renew it from a different thread. - Redis locks, which we use for locking tasks, are thread-local by default, we therefore need to set `thread_local=False`. - We use Redis locks in a couple other places but these are not being accessed by the heartbeat thread. Also: - Improved heartbeat so we don't need to do a heartbeat if the task already completed after the wait, and added exception handling. - Fixed test to give it a bit more time to start (had some failures locally) + have at least one task & queue lock that should be renewed.
- Loading branch information
Showing
3 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters