Skip to content

Commit

Permalink
Fix high CPU usage for redis notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
np5 committed May 2, 2024
1 parent 3824ddb commit 960021f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/base/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ def _subscribe(self, *channels):
p.subscribe(**{channel: self._message_handler for channel in channels})
if self._thread is None:
logger.debug("Start thread")
self._thread = p.run_in_thread(exception_handler=self._exception_handler, daemon=True)
self._thread = p.run_in_thread(
exception_handler=self._exception_handler,
daemon=True,
# sleep_time is a bad name for this important parameter.
# see https://github.com/redis/redis-py/issues/821
# with 60s, problems with the socket will be recovered from,
# and we let the OS do its job.
sleep_time=60.0
)

def _message_handler(self, message):
channel = message['channel']
Expand Down

0 comments on commit 960021f

Please sign in to comment.