Call mark_process_dead on worker pid if prometheus_client is installed (#212)

This commit is contained in:
Andrii Yurchuk
2024-09-03 22:29:00 +02:00
committed by GitHub
parent 48123af09d
commit af505e8d70
2 changed files with 8 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ from django.utils.translation import gettext_lazy as _
# Local
from django_q.brokers import Broker, get_broker
from django_q.conf import Conf, get_ppid, logger, psutil, setproctitle
from django_q.conf import Conf, get_ppid, logger, psutil, setproctitle, prometheus_multiprocess
from django_q.humanhash import humanize
from django_q.monitor import monitor
from django_q.pusher import pusher
@@ -223,6 +223,8 @@ class Sentinel:
% {"name": process.name}
)
else:
if prometheus_multiprocess:
prometheus_multiprocess.mark_process_dead(process.pid)
self.pool.remove(process)
self.spawn_worker()
if process.timer.value == 0:

View File

@@ -38,6 +38,11 @@ try:
except ModuleNotFoundError:
setproctitle = None
try:
from prometheus_client import multiprocess as prometheus_multiprocess
except ModuleNotFoundError:
prometheus_multiprocess = None
class Conf:
"""