| 1 |
from time import sleep |
| 2 |
|
| 3 |
from celery import shared_task |
| 4 |
from t.integration.tasks import LEGACY_TASKS_DISABLED |
| 5 |
|
| 6 |
|
| 7 |
@shared_task |
| 8 |
def waitfor(seconds: int) -> None: |
| 9 |
print(f"Waiting for {seconds} seconds...") |
| 10 |
for i in range(seconds): |
| 11 |
sleep(1) |
| 12 |
print(f"{i+1} seconds passed") |
| 13 |
print("Done waiting") |
| 14 |
|
| 15 |
|
| 16 |
if LEGACY_TASKS_DISABLED: |
| 17 |
from t.integration.tasks import StampedTaskOnReplace, StampOnReplace |
| 18 |
|
| 19 |
@shared_task(bind=True, base=StampedTaskOnReplace) |
| 20 |
def wait_for_revoke(self: StampOnReplace, seconds: int, waitfor_worker_queue) -> None: |
| 21 |
print(f"Replacing {self.request.id} with waitfor({seconds})") |
| 22 |
self.replace(waitfor.s(seconds).set(queue=waitfor_worker_queue)) |