|
@@ -25,7 +25,7 @@ AMQHEARTBEAT_RATE = 2.0
|
|
|
|
|
|
def asynloop(obj, connection, consumer, strategies, ns, hub, qos,
|
|
|
heartbeat, handle_unknown_message, handle_unknown_task,
|
|
|
- handle_invalid_task, sleep=sleep, min=min, Empty=Empty,
|
|
|
+ handle_invalid_task, clock, sleep=sleep, min=min, Empty=Empty,
|
|
|
hbrate=AMQHEARTBEAT_RATE):
|
|
|
"""Non-blocking eventloop consuming messages until connection is lost,
|
|
|
or shutdown is requested."""
|
|
@@ -43,6 +43,7 @@ def asynloop(obj, connection, consumer, strategies, ns, hub, qos,
|
|
|
drain_nowait = connection.drain_nowait
|
|
|
on_task_callbacks = hub.on_task
|
|
|
keep_draining = connection.transport.nb_keep_draining
|
|
|
+ adjust_clock = clock.adjust
|
|
|
|
|
|
if heartbeat and connection.supports_heartbeats:
|
|
|
hub.timer.apply_interval(
|
|
@@ -55,6 +56,9 @@ def asynloop(obj, connection, consumer, strategies, ns, hub, qos,
|
|
|
name = body['task']
|
|
|
except (KeyError, TypeError):
|
|
|
return handle_unknown_message(body, message)
|
|
|
+
|
|
|
+ adjust_clock(body.get('clock') or 0)
|
|
|
+
|
|
|
try:
|
|
|
strategies[name](message, body, message.ack_log_error)
|
|
|
except KeyError as exc:
|
|
@@ -122,8 +126,9 @@ def asynloop(obj, connection, consumer, strategies, ns, hub, qos,
|
|
|
|
|
|
def synloop(obj, connection, consumer, strategies, ns, hub, qos,
|
|
|
heartbeat, handle_unknown_message, handle_unknown_task,
|
|
|
- handle_invalid_task, **kwargs):
|
|
|
+ handle_invalid_task, clock, **kwargs):
|
|
|
"""Fallback blocking eventloop for transports that doesn't support AIO."""
|
|
|
+ adjust_clock = clock.adjust
|
|
|
|
|
|
def on_task_received(body, message):
|
|
|
try:
|
|
@@ -131,6 +136,8 @@ def synloop(obj, connection, consumer, strategies, ns, hub, qos,
|
|
|
except (KeyError, TypeError):
|
|
|
return handle_unknown_message(body, message)
|
|
|
|
|
|
+ adjust_clock(body.get('clock') or 0)
|
|
|
+
|
|
|
try:
|
|
|
strategies[name](message, body, message.ack_log_error)
|
|
|
except KeyError as exc:
|