mirror of
https://github.com/zulip/zulip.git
synced 2026-06-30 21:11:04 +08:00
queue: Only set QOS on a newly-opened channel, once.
As written, the QOS parameters are (re)set every time ensure_queue is
called, which is every time a message is enqueued. This is wasteful --
particularly QOS parameters only apply for consumers, and setting them
takes a RTT to the server.
Switch to only setting the QOS once, when a connection
is (re)established. In profiling, this reduces the time to call
`queue_json_publish("noop", {})` from 878µs to 150µs.
This commit is contained in:
parent
d145644f85
commit
aa032bf62c
@ -160,9 +160,10 @@ class SimpleQueueClient(QueueClient[BlockingChannel]):
|
||||
the callback with no arguments."""
|
||||
if self.connection is None or not self.connection.is_open:
|
||||
self._connect()
|
||||
|
||||
assert self.channel is not None
|
||||
self.channel.basic_qos(prefetch_count=self.prefetch)
|
||||
assert self.channel is not None
|
||||
self.channel.basic_qos(prefetch_count=self.prefetch)
|
||||
else:
|
||||
assert self.channel is not None
|
||||
|
||||
if queue_name not in self.queues:
|
||||
self.channel.queue_declare(queue=queue_name, durable=True)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user