chendm 发表于 2023-11-16 23:13

python sanic 服务启动失败处理经验

python sanic 服务器启动失败 Server Stopped 问题处理
Starting a process: Sanic-Server-0-0
Starting a process: Sanic-Reloader-0
Not all workers are ack. Shutting down.
Experienced exception while trying to serve
Traceback (most recent call last):
File "/data/pyenv/pysanic3/lib/python3.9/site-packages/sanic/mixins/startup.py", line 851, in serve
    manager.run()
File "/data/pyenv/pysanic3/lib/python3.9/site-packages/sanic/worker/manager.py", line 63, in run
    self.monitor()
File "/data/pyenv/pysanic3/lib/python3.9/site-packages/sanic/worker/manager.py", line 99, in monitor
    self.wait_for_ack()
File "/data/pyenv/pysanic3/lib/python3.9/site-packages/sanic/worker/manager.py", line 139, in wait_for_ack
    sys.exit(1)
SystemExit: 1
Server Stopped
解决方法:
/data/pyenv/pysanic3/lib/python3.9/site-packages/sanic/worker/manager.py
manager.py文件的 line 139, in wait_for_ack 相关语句注释掉
    def wait_for_ack(self):# no cov
      misses = 0
      while not self._all_workers_ack():
            sleep(0.1)
            misses += 1
            # if misses > self.THRESHOLD:
            #   error_logger.error("Not all workers are ack. Shutting down.")
            #   self.kill()
            #   sys.exit(1)

遇到相同问题的同学可以借鉴 一下了。


sai609 发表于 2023-11-17 00:18

没有遇到这问题

chendm 发表于 2023-11-29 14:19

sai609 发表于 2023-11-17 00:18
没有遇到这问题

是我摸索出来的,可以解决这个问题,也许新版本修正了此问题
页: [1]
查看完整版本: python sanic 服务启动失败处理经验