Last active
December 17, 2015 12:29
-
-
Save carlohamalainen/5610513 to your computer and use it in GitHub Desktop.
nondeterministic behaviour of inspect().active() in celery
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
######### blah.py ######### | |
from time import sleep | |
from celery import Celery | |
from celery.task import Task | |
import logging | |
import traceback | |
import time | |
import random | |
celery = Celery('blah', backend='redis://localhost', broker='redis://localhost') | |
class SleepTest(Task): | |
def run(self, x): | |
while True: | |
time.sleep(1) | |
logging.debug('sleeping... ' + str(x)) | |
######### run.py ############# | |
from blah import SleepTest | |
for x in range(10): | |
job = SleepTest.apply_async(args=[x], kwargs={}, queue='blah') | |
print job | |
######### running ########### | |
# | |
# celery -A blah worker --loglevel=debug --no-color -Q blah --concurrency 100 | |
####### Code the gives nondeterministic results: | |
from celery import Celery | |
from celery.result import AsyncResult | |
celery = Celery('blah', backend='redis://localhost', broker='redis://localhost') | |
from celery.task.control import inspect | |
print inspect().active() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment