タイプ「XXX」セロリの未登録タスクを受信しました



Received Unregistered Task Type Xxx Celery



[2018-11-06 10:23:48,346: DEBUG/MainProcess] basic.qos: prefetch_count->4 [2018-11-06 10:24:00,129: ERROR/MainProcess] Received unregistered task of type 'rub_jobs.tasktest'. 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'[[], {}, {'callbacks': null, 'errbacks': null, 'chain': null, 'chord': null}]' (77b) Traceback (most recent call last): File 'c:program filespython36libsite-packagesceleryworkerconsumerconsumer.py', line 565, in on_task_received strategy = strategies[type_] KeyError: 'rub_jobs.tasktest'

私はインターネットを検索して答えを見つけました。そこで、セロリのソースを確認し、エラーファイル( 'c: program files python36 lib site-packages celery worker Consumer Consumer.py'、行565)に追加しました。デバッグステートメント



次に、セロリを実行して、印刷されたメッセージを確認します



ご覧のとおり、私自身の仕事はセロリに読まれていません。

したがって、これはパスの問題になるはずです。したがって、デコレータ@ app.taskにパラメータ名を追加することで、セロリで読み取ることができます。

@app.task(name='rub_jobs.tasktest') def tasktest(): print('task test,[%s],args=(%s)' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),None) )

ご覧のとおり、私のrub_jobs.tasktestはセロリによって読み取られました。