中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

django-celery啟動后迅速關閉怎么辦

發布時間:2021-02-02 14:33:07 來源:億速云 閱讀:412 作者:小新 欄目:開發技術

這篇文章給大家分享的是有關django-celery啟動后迅速關閉怎么辦的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

日志中也沒有打印什么明顯的錯誤,只是顯示連接了rabbitmq后就關閉了

[2019-09-11 06:08:45,729: INFO/Beat] beat: Starting...
[2019-09-11 06:08:45,731: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2019-09-11 06:08:45,732: INFO/Beat] Writing entries (0)...
[2019-09-11 06:08:45,740: INFO/MainProcess] mingle: searching for neighbors
[2019-09-11 06:08:45,771: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-09-11 06:08:45,771: INFO/Beat] Writing entries (0)...
[2019-09-11 06:08:46,748: INFO/MainProcess] mingle: all alone
[2019-09-11 06:08:46,749: INFO/MainProcess] beat: Shutting down...
[2019-09-11 06:08:46,749: INFO/Beat] Writing entries (0)...
[2019-09-11 06:08:46,749: INFO/Beat] Writing entries (0)...

查看rabbitmq的日志,這里顯示rabbitmq連接成功,然后就是斷開連接,(但是我還是以為是rabbitmq的問題,因為我在另外一臺主機上一摸一樣的環境沒有問題)

=INFO REPORT==== 15-Oct-2019::02:17:54 ===
connection <0.305.0> (127.0.0.1:39786 -> 127.0.0.1:5672): user 'guest' authenticated and granted access to vhost '/'

=INFO REPORT==== 15-Oct-2019::02:17:56 ===
connection <0.310.0> (127.0.0.1:39788 -> 127.0.0.1:5672): user 'guest' authenticated and granted access to vhost '/'

=WARNING REPORT==== 15-Oct-2019::02:17:57 ===
closing AMQP connection <0.305.0> (127.0.0.1:39786 -> 127.0.0.1:5672, vhost: '/', user: 'guest'):
client unexpectedly closed TCP connection

=INFO REPORT==== 15-Oct-2019::02:17:58 ===
closing AMQP connection <0.310.0> (127.0.0.1:39788 -> 127.0.0.1:5672, vhost: '/', user: 'guest')

=INFO REPORT==== 15-Oct-2019::02:17:58 ===
closing AMQP connection <0.302.0> (127.0.0.1:39780 -> 127.0.0.1:5672, vhost: '/', user: 'guest')

在試了重裝erlang和rabbitmq等服務,折騰了一天后,第二天我換了個思路,從celery源碼查看

找到Shutting down...這個日志輸出的位置

def stop(self, wait=False):
    info('beat: Shutting down...')
    # 這里增加一段代碼
    ''''''
    import traceback
    info("start shutdown traceback ====")
    traceback.print_stack()
    ''''''
    self._is_shutdown.set()
    wait and self._is_stopped.wait() # block until shutdown done.

再次啟動celery后獲得以下日志

[2019-10-16 10:15:15,037: INFO/Beat] beat: Starting...
[2019-10-16 10:15:15,039: INFO/Beat] Writing entries (0)...
[2019-10-16 10:15:15,082: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:15:15,082: INFO/Beat] Writing entries (0)...
[2019-10-16 10:15:15,394: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:15:15,394: INFO/Beat] Writing entries (0)...
[2019-10-16 10:15:16,201: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:15:16,201: INFO/Beat] Writing entries (0)...
[2019-10-16 10:15:16,859: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:15:16,859: INFO/Beat] Writing entries (0)...
[2019-10-16 10:15:23,337: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2019-10-16 10:15:28,102: INFO/Beat] Writing entries (0)...
[2019-10-16 10:15:31,348: INFO/MainProcess] mingle: searching for neighbors
[2019-10-16 10:15:32,357: INFO/MainProcess] mingle: all alone
[2019-10-16 10:15:32,362: WARNING/MainProcess] invalid syntax (strategy.py, line 13)
[2019-10-16 10:15:33,372: INFO/MainProcess] start shutdown traceback ====
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/django/core/management/__init__.py"
, line 381, in execute_from_command_line utility.execute()
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/django/core/management/__init__.py"
, line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv)
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/djcelery/management/commands/celery
.py", line 21, in run_from_argv ['{0[0]} {0[1]}'.format(argv)] + argv[2:],
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/celery.py", line 793, in
execute_from_commandline super(CeleryCommand, self).execute_from_commandline(argv)))
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/base.py", line 311, in e
xecute_from_commandline return self.handle_argv(self.prog_name, argv[1:])
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/celery.py", line 785, in
handle_argv return self.execute(command, argv)
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/celery.py", line 717, in
execute ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/worker.py", line 179, in
run_from_argv return self(*args, **options)
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/base.py", line 274, in _
_call__ ret = self.run(*args, **kwargs)
[2019-10-16 10:15:33,374: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/worker.py", line 212, in
run state_db=self.node_format(state_db, hostname), **kwargs
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/worker/__init__.py", line 21
2, in start self.stop()
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/worker/__init__.py", line 25
4, in stop self._shutdown(warm=True)
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/worker/__init__.py", line 26
8, in _shutdown self.blueprint.stop(self, terminate=not warm)
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bootsteps.py", line 179, in
stop description=what, propagate=False,
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bootsteps.py", line 142, in
restart self.send_all(parent, method, description, propagate=propagate)
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bootsteps.py", line 155, in
send_all fun(parent, *args)
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bootsteps.py", line 378, in
stop return self.obj.stop()
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/beat.py", line 559, in stop
self.service.stop()
[2019-10-16 10:15:33,375: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/beat.py", line 499, in stop
traceback.print_stack()
[2019-10-16 10:15:33,375: INFO/MainProcess] beat: Shutting down...
[2019-10-16 10:15:33,375: INFO/Beat] Writing entries (0)...
[2019-10-16 10:15:33,376: INFO/Beat] Writing entries (0)...
[root@test operations]# [2019-10-16 10:15:51,178: INFO/Beat] Writing entries (0)...
[2019-10-16 10:16:30,352: INFO/Beat] Writing entries (0)...
[2019-10-16 10:16:46,806: INFO/Beat] Writing entries (0)...
[2019-10-16 10:18:56,064: INFO/Beat] Writing entries (0)...
[2019-10-16 10:19:35,231: INFO/Beat] Writing entries (0)...
[2019-10-16 10:19:51,689: INFO/Beat] Writing entries (0)...

可以看出在/usr/local/python3/lib/python3.7/site-packages/celery/worker/__init__.py中的start方法中執行了stop方法,在stop中打印了beat: Shutting down...字符

def start(self):
    """Starts the workers main loop."""
    '''
    修改start方法,去掉try,以便找到錯誤位置
    '''
    self.blueprint.start(self)
    #try:
    #  self.blueprint.start(self)
    #except WorkerTerminate:
    #  self.terminate()
    #except Exception as exc:

    #  logger.error('Unrecoverable error: %r', exc, exc_info=True)
    #  self.stop()
    #except (KeyboardInterrupt, SystemExit):
    #  self.stop()

然后再次啟動celery獲得以下日志

[2019-10-16 10:19:57,241: INFO/Beat] beat: Starting...
[2019-10-16 10:19:57,244: INFO/Beat] Writing entries (0)...
[2019-10-16 10:19:57,287: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:19:57,287: INFO/Beat] Writing entries (0)...
[2019-10-16 10:20:00,218: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:20:00,218: INFO/Beat] Writing entries (0)...
[2019-10-16 10:20:01,023: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:20:01,023: INFO/Beat] Writing entries (0)...
[2019-10-16 10:20:01,685: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:20:01,685: INFO/Beat] Writing entries (0)...
[2019-10-16 10:20:05,548: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2019-10-16 10:20:10,307: INFO/Beat] Writing entries (0)...
[2019-10-16 10:20:13,561: INFO/MainProcess] mingle: searching for neighbors
[2019-10-16 10:20:14,570: INFO/MainProcess] mingle: all alone
[2019-10-16 10:20:14,571: WARNING/MainProcess] Traceback (most recent call last):
[2019-10-16 10:20:14,571: WARNING/MainProcess] File "manage.py", line 15, in <module>
[2019-10-16 10:20:14,571: WARNING/MainProcess] execute_from_command_line(sys.argv)
[2019-10-16 10:20:14,571: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/django/core/management/__init__.py"
, line 381, in execute_from_command_line[2019-10-16 10:20:14,572: WARNING/MainProcess] utility.execute()
[2019-10-16 10:20:14,572: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/django/core/management/__init__.py"
, line 375, in execute[2019-10-16 10:20:14,572: WARNING/MainProcess] self.fetch_command(subcommand).run_from_argv(self.argv)
[2019-10-16 10:20:14,572: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/djcelery/management/commands/celery
.py", line 21, in run_from_argv[2019-10-16 10:20:14,572: WARNING/MainProcess] ['{0[0]} {0[1]}'.format(argv)] + argv[2:],
[2019-10-16 10:20:14,572: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/celery.py", line 793, in
execute_from_commandline[2019-10-16 10:20:14,573: WARNING/MainProcess] super(CeleryCommand, self).execute_from_commandline(argv)))
[2019-10-16 10:20:14,573: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/base.py", line 311, in e
xecute_from_commandline[2019-10-16 10:20:14,573: WARNING/MainProcess] return self.handle_argv(self.prog_name, argv[1:])
[2019-10-16 10:20:14,573: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/celery.py", line 785, in
handle_argv[2019-10-16 10:20:14,574: WARNING/MainProcess] return self.execute(command, argv)
[2019-10-16 10:20:14,574: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/celery.py", line 717, in
execute[2019-10-16 10:20:14,574: WARNING/MainProcess] ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
[2019-10-16 10:20:14,574: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/worker.py", line 179, in
run_from_argv[2019-10-16 10:20:14,574: WARNING/MainProcess] return self(*args, **options)
[2019-10-16 10:20:14,575: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/base.py", line 274, in _
_call__[2019-10-16 10:20:14,575: WARNING/MainProcess] ret = self.run(*args, **kwargs)
[2019-10-16 10:20:14,575: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bin/worker.py", line 212, in
run[2019-10-16 10:20:14,575: WARNING/MainProcess] state_db=self.node_format(state_db, hostname), **kwargs
[2019-10-16 10:20:14,575: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/worker/__init__.py", line 20
5, in start[2019-10-16 10:20:14,575: WARNING/MainProcess] self.blueprint.start(self)
[2019-10-16 10:20:14,575: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bootsteps.py", line 123, in
start[2019-10-16 10:20:14,576: WARNING/MainProcess] step.start(parent)
[2019-10-16 10:20:14,576: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bootsteps.py", line 374, in
start[2019-10-16 10:20:14,576: WARNING/MainProcess] return self.obj.start()
[2019-10-16 10:20:14,576: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/worker/consumer.py", line 28
0, in start[2019-10-16 10:20:14,576: WARNING/MainProcess] blueprint.start(self)
[2019-10-16 10:20:14,577: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/bootsteps.py", line 123, in
start[2019-10-16 10:20:14,577: WARNING/MainProcess] step.start(parent)
[2019-10-16 10:20:14,577: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/worker/consumer.py", line 64
2, in start[2019-10-16 10:20:14,577: WARNING/MainProcess] c.update_strategies()
[2019-10-16 10:20:14,577: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/worker/consumer.py", line 43
9, in update_strategies[2019-10-16 10:20:14,578: WARNING/MainProcess] self.strategies[name] = task.start_strategy(self.app, self)
[2019-10-16 10:20:14,578: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/app/task.py", line 448, in s
tart_strategy[2019-10-16 10:20:14,578: WARNING/MainProcess] return instantiate(self.Strategy, self, app, consumer, **kwargs)
[2019-10-16 10:20:14,578: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/utils/imports.py", line 53,
in instantiate[2019-10-16 10:20:14,578: WARNING/MainProcess] return symbol_by_name(name)(*args, **kwargs)
[2019-10-16 10:20:14,578: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/kombu/utils/__init__.py", line 96,
in symbol_by_name[2019-10-16 10:20:14,578: WARNING/MainProcess] module = imp(module_name, package=package, **kwargs)
[2019-10-16 10:20:14,579: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/importlib/__init__.py", line 127, in import_modul
e[2019-10-16 10:20:14,579: WARNING/MainProcess] return _bootstrap._gcd_import(name[level:], package, level)
[2019-10-16 10:20:14,579: WARNING/MainProcess] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
[2019-10-16 10:20:14,579: WARNING/MainProcess] File "<frozen importlib._bootstrap>", line 983, in _find_and_load
[2019-10-16 10:20:14,579: WARNING/MainProcess] File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
[2019-10-16 10:20:14,579: WARNING/MainProcess] File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
[2019-10-16 10:20:14,579: WARNING/MainProcess] File "<frozen importlib._bootstrap_external>", line 724, in exec_module
[2019-10-16 10:20:14,579: WARNING/MainProcess] File "<frozen importlib._bootstrap_external>", line 860, in get_code
[2019-10-16 10:20:14,580: WARNING/MainProcess] File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
[2019-10-16 10:20:14,580: WARNING/MainProcess] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[2019-10-16 10:20:14,580: WARNING/MainProcess] File "/usr/local/python3/lib/python3.7/site-packages/celery/worker/strategy.py", line 13
[2019-10-16 10:20:14,580: WARNING/MainProcess] from kombu.async.timer import to_timestamp
[2019-10-16 10:20:14,580: WARNING/MainProcess] ^
[2019-10-16 10:20:14,580: WARNING/MainProcess] SyntaxError
[2019-10-16 10:20:14,580: WARNING/MainProcess] :
[2019-10-16 10:20:14,580: WARNING/MainProcess] invalid syntax

可以看到from kombu.async.timer import to_timestamp這句導包的時候報錯 在kombu中把async目錄修改成了asynchronous,同時因為python3.7以后吧async變成了一個關鍵字,不能作為包來引用,因此報錯,所以修改async為asynchronous

再次啟動celery后獲得以下日志

[2019-10-16 10:27:14,497: INFO/Beat] beat: Starting...
[2019-10-16 10:27:14,500: INFO/Beat] Writing entries (0)...
[2019-10-16 10:27:14,545: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:27:14,545: INFO/Beat] Writing entries (0)...
[2019-10-16 10:27:14,949: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:27:14,949: INFO/Beat] Writing entries (0)...
[2019-10-16 10:27:15,029: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:27:15,029: INFO/Beat] Writing entries (0)...
[2019-10-16 10:27:15,748: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:27:15,748: INFO/Beat] Writing entries (0)...
[2019-10-16 10:27:16,427: INFO/Beat] DatabaseScheduler: Schedule changed.
[2019-10-16 10:27:16,427: INFO/Beat] Writing entries (0)...
[2019-10-16 10:27:22,485: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2019-10-16 10:27:24,618: INFO/MainProcess] mingle: searching for neighbors
[2019-10-16 10:27:25,626: INFO/MainProcess] mingle: all alone
[2019-10-16 10:27:25,648: WARNING/MainProcess] /usr/local/python3/lib/python3.7/site-packages/djcelery/loaders.py:133: UserWarning: Usi
ng settings.DEBUG leads to a memory leak, never use this setting in production environments! warn('Using settings.DEBUG leads to a memory leak, never '
[2019-10-16 10:27:25,648: WARNING/MainProcess] celery@test.ylyw.com ready.

當出現celery@test.ylyw.com ready.后,就可以確定celery正常運行了

感謝各位的閱讀!關于“django-celery啟動后迅速關閉怎么辦”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

明光市| 北票市| 根河市| 芷江| 义乌市| 安丘市| 牡丹江市| 姜堰市| 松原市| 张家川| 盘锦市| 衡山县| 宣恩县| 东城区| 通江县| 怀化市| 无锡市| 昌江| 民权县| 栾城县| 扎囊县| 平遥县| 固始县| 灌阳县| 汽车| 朔州市| 密山市| 芦溪县| 新宁县| 安阳市| 孝感市| 泗洪县| 延寿县| 双鸭山市| 中阳县| 根河市| 共和县| 千阳县| 苍溪县| 富顺县| 建平县|