启动后错误会一直刷屏,不得不停止掉
(joyoo) E:\yinzhuoqun\djangos\joyoo>celery -A joyoo worker -l info
raven.contrib.django.client.DjangoClient: 2019-12-18 19:52:57,763 e:\py_virtualenv\joyoo\lib\site-packages\raven\base.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.
-------------- celery@DESKTOP-9K42C1Q v4.3.0 (rhubarb)
---- **** -----
--- * *** * -- Windows-10-10.0.17763-SP0 2019-12-18 19:52:59
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: joyoo:0x1e0b5ae56a0
- ** ---------- .> transport: redis://127.0.0.1:6379/0
- ** ---------- .> results:
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
[tasks]
. blog.tasks.task_check_friend_url
. blog.tasks.task_save_view_page
. blog.tasks.task_send_dd_text
. blog.tasks.task_send_mail
[2019-12-18 19:52:59,830: INFO/MainProcess] Connected to redis://127.0.0.1:6379/0
[2019-12-18 19:52:59,838: INFO/MainProcess] mingle: searching for neighbors
[2019-12-18 19:53:00,745: INFO/SpawnPoolWorker-4] child process 23668 calling self.run()
[2019-12-18 19:53:00,817: INFO/SpawnPoolWorker-2] child process 14316 calling self.run()
[2019-12-18 19:53:00,853: INFO/SpawnPoolWorker-3] child process 13964 calling self.run()
[2019-12-18 19:53:00,860: INFO/MainProcess] mingle: all alone
[2019-12-18 19:53:00,865: INFO/SpawnPoolWorker-1] child process 16068 calling self.run()
[2019-12-18 19:53:00,875: WARNING/MainProcess] e:\py_virtualenv\joyoo\lib\site-packages\celery\fixups\django.py:202: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn('Using settings.DEBUG leads to a memory leak, never '
[2019-12-18 19:53:00,877: INFO/MainProcess] celery@DESKTOP-9K42C1Q ready.
[2019-12-18 19:53:01,062: ERROR/MainProcess] Received unregistered task of type 'apps.share.tasks.post_to_beiqia'.
The message has been ignored and discarded.
Did you remember to import the module containing this task?
Or maybe you're using relative imports?
Please see
http://docs.celeryq.org/en/latest/internals/protocol.html
for more information.
The full contents of the message body was:
b'\x80\x02}q\x00(X\x04\x00\x00\x00taskq\x01X\x1f\x00\x00\x00apps.share.tasks.post_to_beiqiaq\x02X\x02\x00\x00\x00idq\x03X$\x00\x00\x0018c5f274-d24c-44da-8fce-9a7f60166aebq\x04X\x04\x00\x00\x00argsq\x05]q\x06X\x06\x00\x00\x00kwargsq\x07}q\x08X\x07\x00\x00\x00retriesq\tK\x00X\x03\x00\x00\x00etaq\nNX\x07\x00\x00\x00expiresq\x0bNX\x03\x00\x00\x00utcq\x0c\x88X\t\x00\x00\x00callbacksq\rNX\x08\x00\x00\x00errbacksq\x0eNX\t\x00\x00\x00timelimitq\x0fNN\x86q\x10X\x07\x00\x00\x00tasksetq\x11NX\x05\x00\x00\x00chordq\x12Nu.' (274b)
Traceback (most recent call last):
File "e:\py_virtualenv\joyoo\lib\site-packages\celery\worker\consumer\consumer.py", line 559, in on_task_received
strategy = strategies[type_]
KeyError: 'apps.share.tasks.post_to_beiqia'
本机有多个 django 项目,另外个项目也是用过 celery,“apps.share.tasks.post_to_beiqia”是另一个 django 项目的 task,所以说是 celery 找到了另外个项目的任务了,为什么能找到,猜想是 中间人是同一个(同 redis 同库),那么为什么之前 任务还在呢,redis 持久化造成的,所以解决方案有如下:
redis 0 里面的数据
(joyoo) E:\yinzhuoqun\djangos\joyoo>celery -A joyoo worker -l info
raven.contrib.django.client.DjangoClient: 2019-12-19 14:11:05,505 e:\py_virtualenv\joyoo\lib\site-packages\raven\base.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.
-------------- celery@DESKTOP-9K42C1Q v4.3.0 (rhubarb)
---- **** -----
--- * *** * -- Windows-10-10.0.17763-SP0 2019-12-19 14:11:07
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: joyoo:0x28386ac1748
- ** ---------- .> transport: redis://127.0.0.1:6379/0
- ** ---------- .> results:
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
[tasks]
. blog.tasks.task_check_friend_url
. blog.tasks.task_save_view_page
. blog.tasks.task_send_dd_text
. blog.tasks.task_send_mail
[2019-12-19 14:11:07,648: INFO/MainProcess] Connected to redis://127.0.0.1:6379/0
[2019-12-19 14:11:07,658: INFO/MainProcess] mingle: searching for neighbors
[2019-12-19 14:11:08,679: INFO/MainProcess] mingle: all alone
[2019-12-19 14:11:08,705: WARNING/MainProcess] e:\py_virtualenv\joyoo\lib\site-packages\celery\fixups\django.py:202: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn('Using settings.DEBUG leads to a memory leak, never '
[2019-12-19 14:11:08,721: INFO/MainProcess] celery@DESKTOP-9K42C1Q ready.
[2019-12-19 14:11:08,752: INFO/SpawnPoolWorker-4] child process 15256 calling self.run()
[2019-12-19 14:11:08,754: INFO/SpawnPoolWorker-2] child process 6736 calling self.run()
[2019-12-19 14:11:08,763: INFO/SpawnPoolWorker-1] child process 3444 calling self.run()
[2019-12-19 14:11:08,775: INFO/SpawnPoolWorker-3] child process 20720 calling self.run()
raven.contrib.django.client.DjangoClient: 2019-12-19 14:11:15,158 e:\py_virtualenv\joyoo\lib\site-packages\raven\base.py [line:213] INFO Raven is not configured (logging is disabled). Please see the documentation for more information.