Skip to content
/ sir Public

Commit 6efb97e

Browse files
amCap1712mwiencek
andauthored
SEARCH-665: Move connection/channel assignments (#122)
Fix "RuntimeError: maximum recursion depth exceeded in cmp" error. It is assumed that sometimes acking a message fails, so the `action_wrapper` decorator tries to reconnect to rabbitmq calling `connect_to_rabbitmq` method, which re-does adding the callbacks, then the new added callback fails, setting up a chain reaction. See also https://chatlogs.metabrainz.org/libera/metabrainz/msg/4848594/ Co-authored-by: Michael Wiencek <mwtuea@gmail.com>
1 parent 2c09581 commit 6efb97e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sir/amqp/handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@ def add_handler(queue, f, channel):
196196
self.connection.close()
197197

198198
conn = create_amqp_connection()
199+
self.connection = conn
199200
logger.debug("Heartbeat value: %s" % conn.heartbeat)
200201
ch = conn.channel()
202+
self.channel = ch
201203
# Keep in mind that `prefetch_size` is not supported by the version of RabbitMQ that
202204
# we are currently using (https://www.rabbitmq.com/specification.html).
203205
# Limits are requires because consumer connection might time out when receive buffer
@@ -207,8 +209,6 @@ def add_handler(queue, f, channel):
207209

208210
add_handler("search.index", self.index_callback, ch)
209211
add_handler("search.delete", self.delete_callback, ch)
210-
self.connection = conn
211-
self.channel = ch
212212

213213
@action_wrapper
214214
def requeue_message(self, msg, exc, fail=False):

0 commit comments

Comments
 (0)