Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files

Open/Close the connection to rabbitmq every time we need one

For some reason, if we create one connection and re-use it everywhere
(which would still be the ideal situation) after a little while, we run
into: ConnectionClosed exception.

With this change, fedmsg-hub is happily running for over 12h now.
  • Loading branch information...
pypingou committed Jul 19, 2016
1 parent 9ebcf9b commit 38f59ab22a9556f27b725a2bcbf911ab2a34f32f
Showing with 7 additions and 4 deletions.
  1. +7 −4 fmn/consumer/
@@ -20,13 +20,15 @@
log = logging.getLogger("fmn")

import pika
connection = pika.BlockingConnection()
OPTS = pika.ConnectionParameters(

def notify_prefs_change(openid):
import json
import pika
connection = pika.BlockingConnection()
connection = pika.BlockingConnection(OPTS)
msg_id = '%s-%s' % (datetime.datetime.utcnow().year, uuid.uuid4())
queue = 'refresh'
chan =
@@ -176,6 +178,7 @@ def work(self, session, raw_msg):
# should receive this message.

import json
connection = pika.BlockingConnection(OPTS)
channel =
channel.queue_declare('workers', durable=True)
@@ -188,11 +191,11 @@ def work(self, session, raw_msg):

log.debug("Done. %0.2fs %s %s",
time.time() - start, msg['msg_id'], msg['topic'])

def stop(self):"Cleaning up FMNConsumer.")
super(FMNConsumer, self).stop()

0 comments on commit 38f59ab

Please sign in to comment.
You can’t perform that action at this time.