Skip to content

Commit

Permalink
fix: reduce latency of AsyncResult.get under gevent (celery#7052)
Browse files Browse the repository at this point in the history
Wakeup waiters in `wait_for` after every `drain_events` occurs instead of only after 1 seconds timeout.

Does not block event loop, because `drain_events` of asynchronous backends with pubsub commonly sleeping for some nonzero time while waiting events.
  • Loading branch information
mrmaxi committed Nov 14, 2021
1 parent 4e1fc5a commit a2792a7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions t/unit/backends/test_asynchronous.py
Expand Up @@ -158,7 +158,10 @@ def sleep(self):

def result_consumer_drain_events(self, timeout=None):
import eventlet
eventlet.sleep(0)
# `drain_events` of asynchronous backends with pubsub have to sleep
# while waiting events for not more then `interval` timeout,
# but events may coming sooner
eventlet.sleep(timeout/10)

def schedule_thread(self, thread):
import eventlet
Expand Down Expand Up @@ -204,7 +207,10 @@ def sleep(self):

def result_consumer_drain_events(self, timeout=None):
import gevent
gevent.sleep(0)
# `drain_events` of asynchronous backends with pubsub have to sleep
# while waiting events for not more then `interval` timeout,
# but events may coming sooner
gevent.sleep(timeout/10)

def schedule_thread(self, thread):
import gevent
Expand Down

0 comments on commit a2792a7

Please sign in to comment.