Skip to content

Instantly share code, notes, and snippets.

@bdeeney
bdeeney / gist:4503584
Last active December 10, 2015 22:38
Connection.Close from server triggers ConnectionClosed exception in async consumer (using pika 0.9.8)
DEBUG 2013-01-10 11:32:04,685 pika.adapters.select_connection poll 439 : Calling <bound method SelectConnection._handle_events of <pika.adapters.select_connection.SelectConnection object at 0x166ca50>>
DEBUG 2013-01-10 11:32:04,685 pika.connection _process_frame 1179: Frame: <METHOD(['frame_type=1', 'channel_number=0', "method=<Connection.Close(['class_id=0', 'method_id=0', 'reply_code=320', 'reply_text=CONNECTION_FORCED - Closed via management plugin'])>"])>
DEBUG 2013-01-10 11:32:04,685 pika.callback process 216 : Processing 0:Connection.Close
DEBUG 2013-01-10 11:32:04,685 pika.callback _use_one_shot_callback 389 : Processing use of oneshot callback
DEBUG 2013-01-10 11:32:04,685 pika.callback _use_one_shot_callback 391 : 0 registered uses left
DEBUG 2013-01-10 11:32:04,685 pika.callback
@bdeeney
bdeeney / example_consumer.py
Created December 6, 2012 13:13
An example consumer that cleanly handles events from RabbitMQ such as connection closures.
import logging
import pika
LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s')
LOGGER = logging.getLogger(__name__)
class ExampleConsumer(object):
"""This is an example consumer that will handle unexpected interactions
# Copyright 2011-2012 Canonical Ltd
# -*- coding: utf-8 -*-
import httplib2
import json
import operator
import re
import time
import record
import datetime