Skip to content

Commit

Permalink
Call mark_process_dead on worker pid if prometheus_client is installed (
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch00k authored Sep 3, 2024
1 parent 48123af commit af505e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion django_q/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# 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
Expand Down Expand Up @@ -223,6 +223,8 @@ def reincarnate(self, process):
% {"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:
Expand Down
5 changes: 5 additions & 0 deletions django_q/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
except ModuleNotFoundError:
setproctitle = None

try:
from prometheus_client import multiprocess as prometheus_multiprocess
except ModuleNotFoundError:
prometheus_multiprocess = None


class Conf:
"""
Expand Down

0 comments on commit af505e8

Please sign in to comment.