-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/ay/async-geo-case-reassignment-t…
…est' into autostaging
- Loading branch information
Showing
11 changed files
with
522 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from celery import states | ||
from celery.result import AsyncResult | ||
|
||
from corehq.apps.celery import task | ||
from corehq.apps.geospatial.utils import update_cases_owner | ||
|
||
|
||
@task(queue="background_queue", ignore_result=False) | ||
def geo_cases_reassignment_update_owners(domain, case_id_to_owner_id): | ||
from time import sleep | ||
sleep(30) | ||
update_cases_owner(domain, case_id_to_owner_id) | ||
|
||
|
||
def is_task_invoked_and_not_completed(task_id): | ||
"""Returns True is a task is invoked and is executing or waiting to be executed. | ||
NOTE: Only works for tasks that store results i.e. ignore_result must be False. | ||
NOTE: Celery states.PENDING is a bit ambiguous as it could mean two things one, task was never invoked and two | ||
task was invoked but still waiting to picked up. | ||
However, in HQ we set state to `SENT` as soon as it is invoked. | ||
See 'casexml.apps.phone.tasks.update_celery_state' | ||
""" | ||
result = AsyncResult(task_id) | ||
return result.state not in [states.PENDING, states.SUCCESS, states.FAILURE, states.REVOKED] |
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
Oops, something went wrong.