Я строю работника сельдерея с целью запуска одной задачи каждые n секунд только один раз. Я вижу записи журнала. И я вижу, что это нерестилища. Поэтому метод вызывается.Деревообрабатывающий динозавр порождает несколько процессов для одиночной периодической задачи, игнорируя run_every
#portfolio-builder.py
from celery import Celery
from celery.task import periodic_task
from datetime import timedelta
REDIS_URL = "A PROPERLY FORMATTED REDIS URL APPEARED"
app = Celery('tasks')
app.conf.update(BROKER_URL=REDIS_URL,
CELERY_RESULT_BACKEND=REDIS_URL)
@periodic_task(run_every=timedelta(seconds=30))
def build_portfolios():
logger = build_portfolios.get_logger()
logger.info("building portfolios")
И я бегу работника с помощью PROCFILE:
worker: celery worker --app=portfolio-builder.app --loglevel=INFO
worker: celery beat --app=portfolio-builder --loglevel=INFO
я запускаю команду
heroku local
worker.1 | [2015-11-05 18:37:00,279: INFO/MainProcess] beat: Starting...
worker.1 | [2015-11-05 18:37:00,309: WARNING/MainProcess] /Users/user/Documents/Project-Raptor/Raptor-Portfolio-Builder/ENV/lib/python2.7/site-packages/celery/apps/worker.py:161: CDeprecationWarning:
worker.1 | [2015-11-05 18:37:00,917: INFO/MainProcess] Scheduler: Sending due task portfolio-builder.build_portfolios (portfolio-builder.build_portfolios)
worker.1 | [2015-11-05 18:37:01,215: INFO/MainProcess] Connected to ****//
worker.1 | [2015-11-05 18:37:01,611: INFO/MainProcess] mingle: searching for neighbors
worker.1 | [2015-11-05 18:37:03,016: INFO/MainProcess] mingle: all alone
worker.1 | [2015-11-05 18:37:03,538: WARNING/MainProcess] [email protected] ready.
worker.1 | [2015-11-05 18:37:03,786: INFO/MainProcess] Received task: portfolio-builder.build_portfolios[8765efc9-f355-4eb9-8afe-385d4f6c6b84]
worker.1 | [2015-11-05 18:37:03,787: INFO/Worker-4] portfolio-builder.build_portfolios[8765efc9-f355-4eb9-8afe-385d4f6c6b84]: building portfolios
worker.1 | [2015-11-05 18:37:03,827: INFO/MainProcess] Task portfolio-builder.build_portfolios[8765efc9-f355-4eb9-8afe-385d4f6c6b84] succeeded in 0.0396841909969s: None
worker.1 | [2015-11-05 18:37:03,867: INFO/MainProcess] Received task: portfolio-builder.build_portfolios[3c6bd54a-2eeb-485d-a737-df752ee93650]
worker.1 | [2015-11-05 18:37:03,869: INFO/Worker-3] portfolio-builder.build_portfolios[3c6bd54a-2eeb-485d-a737-df752ee93650]: building portfolios
worker.1 | [2015-11-05 18:37:03,908: INFO/MainProcess] Task portfolio-builder.build_portfolios[3c6bd54a-2eeb-485d-a737-df752ee93650] succeeded in 0.0399794020341s: None
worker.1 | [2015-11-05 18:37:03,949: INFO/MainProcess] Received task: portfolio-builder.build_portfolios[7d4e8fe9-5dad-42af-b7a8-f6e141fa7835]
worker.1 | [2015-11-05 18:37:03,951: INFO/Worker-2] portfolio-builder.build_portfolios[7d4e8fe9-5dad-42af-b7a8-f6e141fa7835]: building portfolios
worker.1 | [2015-11-05 18:37:03,992: INFO/MainProcess] Task portfolio-builder.build_portfolios[7d4e8fe9-5dad-42af-b7a8-f6e141fa7835] succeeded in 0.0424436000176s: None
worker.1 | [2015-11-05 18:37:04,033: INFO/MainProcess] Received task: portfolio-builder.build_portfolios[848cd495-d063-4e1e-95bf-1636a338659a]
worker.1 | [2015-11-05 18:37:04,035: INFO/Worker-8] portfolio-builder.build_portfolios[848cd495-d063-4e1e-95bf-1636a338659a]: building portfolios
worker.1 | [2015-11-05 18:37:04,074: INFO/MainProcess] Task portfolio-builder.build_portfolios[848cd495-d063-4e1e-95bf-1636a338659a] succeeded in 0.0397574069793s: None
worker.1 | [2015-11-05 18:37:04,115: INFO/MainProcess] Received task: portfolio-builder.build_portfolios[f9adf726-1e26-44ef-ab5e-c05e994553e9]
worker.1 | [2015-11-05 18:37:04,116: INFO/Worker-5] portfolio-builder.build_portfolios[f9adf726-1e26-44ef-ab5e-c05e994553e9]: building portfolios
worker.1 | [2015-11-05 18:37:04,156: INFO/MainProcess] Task portfolio-builder.build_portfolios[f9adf726-1e26-44ef-ab5e-c05e994553e9] succeeded in 0.0404749789741s: None
worker.1 | [2015-11-05 18:37:04,197: INFO/MainProcess] Received task: portfolio-builder.build_portfolios[f994ebae-2860-47ee-98df-db8488d6e01f]
worker.1 | [2015-11-05 18:37:04,199: INFO/Worker-1] portfolio-builder.build_portfolios[f994ebae-2860-47ee-98df-db8488d6e01f]: building portfolios
worker.1 | [2015-11-05 18:37:04,239: INFO/MainProcess] Task portfolio-builder.build_portfolios[f994ebae-2860-47ee-98df-db8488d6e01f] succeeded in 0.0405924500083s: None
worker.1 | [2015-11-05 18:37:04,280: INFO/MainProcess] Received task: portfolio-builder.build_portfolios[27c31f19-7f79-413b-9b0a-e467bd2d0c42]
worker.1 | [2015-11-05 18:37:04,282: INFO/Worker-7] portfolio-builder.build_portfolios[27c31f19-7f79-413b-9b0a-e467bd2d0c42]: building portfolios
worker.1 | [2015-11-05 18:37:04,321: INFO/MainProcess] Task portfolio-builder.build_portfolios[27c31f19-7f79-413b-9b0a-e467bd2d0c42] succeeded in 0.0400763470097s: None
worker.1 | [2015-11-05 18:37:04,362: INFO/MainProcess] Received task: portfolio-builder.build_portfolios[f2c5042c-146e-4b9b-9bc7-a156ef250bf8]
worker.1 | [2015-11-05 18:37:04,363: INFO/Worker-6] portfolio-builder.build_portfolios[f2c5042c-146e-4b9b-9bc7-a156ef250bf8]: building portfolios
worker.1 | [2015-11-05 18:37:04,403: INFO/MainProcess] Task portfolio-builder.build_portfolios[f2c5042c-146e-4b9b-9bc7-a156ef250bf8] succeeded in 0.0400690860115s: None
Мое намерение запустить этот рабочий каждые 30 секунд только на одном рабочем процессе. Но при запуске он появляется на нескольких рабочих процессах. Также я намереваюсь запустить это на Heroku, поэтому, если есть какие-то специальные предостережения, я был бы признателен за помощь!