django Celery Eventlet OSError:无法获得负载平均值

bfrts1fy  于 2023-06-25  发布在  Go
关注(0)|答案(1)|浏览(114)

我们的django celery服务器以500的并发值运行,eventlet作为执行池。最近,我们遇到了这个问题,重新启动服务器修复了它。我附上了错误的追溯。

**python包版本:**Django 4.1.7celery 5.2.3 eventlet 0.33.3

我检查了打开文件的软限制和硬限制,如果这些有任何用处的话。

软限制:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31071
max locked memory       (kbytes, -l) 65536
max memory size         (kbytes, -m) unlimited
open files                      (-n) 2048
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31071
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

硬限制:

core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31071
max locked memory       (kbytes, -l) 65536
max memory size         (kbytes, -m) unlimited
open files                      (-n) 16384
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31071
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

在过去的6或7个月里,我一直在使用Eventlet,这是我们第一次面对这个问题。我们如何防止这种情况再次发生

Traceback (most recent call last):
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/eventlet/hubs/hub.py", line 476, in fire_timers
  timer()
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/eventlet/hubs/timer.py", line 59, in __call__
  cb(*args, **kw)
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/eventlet/greenthread.py", line 224, in main
  self._resolve_links()
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/eventlet/greenthread.py", line 240, in _resolve_links
  f(self, *ca, **ckw)
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/celery/concurrency/eventlet.py", line 62, in _entry_exit
  g.wait()
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/eventlet/greenthread.py", line 181, in wait
  return self._exit_event.wait()
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/eventlet/event.py", line 132, in wait
  current.throw(*self._exc)
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/eventlet/greenthread.py", line 221, in main
  result = function(*args, **kwargs)
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/kombu/asynchronous/timer.py", line 70, in __call__
  return self.fun(*self.args, **self.kwargs)
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/kombu/asynchronous/timer.py", line 137, in _reschedules
  return fun(*args, **kwargs)
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/celery/worker/heartbeat.py", line 45, in _send
  loadavg=load_average(),
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/celery/utils/sysinfo.py", line 23, in load_average
  return _load_average()
 File "/home/ubuntu/project_data/venv/lib/python3.10/site-packages/celery/utils/sysinfo.py", line 13, in _load_average
  return tuple(ceil(l * 1e2) / 1e2 for l in os.getloadavg())
OSError: Load averages are unobtainable
yvgpqqbh

yvgpqqbh1#

getloadavg()方法返回过去1分钟、5分钟和15分钟的平均负载。
这表示系统运行队列中的进程数(在过去的1、5和15分钟内)。
试试这个:load1, load5, load15 = os.getloadavg()

相关问题