<div>
                    <br>
                </div>
                <div></div>
                 
                <p style="color: #a0a0a0;">On Thursday, July 28, 2011 at 6:45 PM, Christian Haintz wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div>Hi,<br><br>I want to stop the consuming loop of a BlockingConnection after some <br>timeout. I used the following code. Producer is not running because I<br>want to simulate the timeout. Current pika version is used from github.<br></div></div></span></blockquote><div>I'd not consider the master branch on Pika stable, which is one of the reasons I've not tagged 0.9.6. I'd do a pip install of 0.9.5 and see if that solves your problem.&nbsp;</div><div><br></div><div>Gavin</div><div><br></div><div>&nbsp;</div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><br>--------8&lt;--------- snip ----------8&lt;-----------<br>import pika<br>connection = pika.BlockingConnection(pika.ConnectionParameters(<br>                                 host='localhost'))<br><br>channel = connection.channel()<br><br>result = channel.queue_declare(exclusive=True)<br>callback_queue = result.method.queue<br><br>def on_response(self, ch, method, props, body):<br>    #do some processing<br>    channel.stop_consuming()<br><br># normaly i do some publish here but that's not relevant<br># to reproduce the error<br><br>channel.basic_consume(on_response, no_ack=True,<br>    queue=callback_queue)<br><br>def panic():<br>    channel.stop_consuming()<br><br>connection.add_timeout(1, panic)<br>channel.start_consuming()<br><br>--------8&lt;------- snip end --------8&lt;-----------<br><br>But I get the following error:<br><br>--------8&lt;--------- snip ----------8&lt;-----------<br>$ python pika_test.py<br>/Users/christian/devel/pika/pika/callback.py:69: UserWarning: <br>CallbackManager.add: Duplicate callback found for "1:Basic.CancelOk"<br>   (self.__class__.__name__, prefix, key))<br>Traceback (most recent call last):<br>   File "pika_test.py", line 21, in &lt;module&gt;<br>     channel.start_consuming()<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>307, in start_consuming<br>     self.transport.connection.process_data_events()<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>104, in process_data_events<br>     self.process_timeouts()<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>164, in process_timeouts<br>     self._timeouts[timeout_id]['handler']()<br>   File "pika_test.py", line 18, in panic<br>     channel.stop_consuming()<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>318, in stop_consuming<br>     self.basic_cancel(consumer_tag)<br>   File "/Users/christian/devel/pika/pika/channel.py", line 333, in <br>basic_cancel<br>     self._on_cancel_ok, [spec.Basic.CancelOk])<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>220, in rpc<br>     self.send_method(method, None, wait)<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>249, in send_method<br>     self.connection.process_data_events()<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>104, in process_data_events<br>     self.process_timeouts()<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>164, in process_timeouts<br>     self._timeouts[timeout_id]['handler']()<br>   File "pika_test.py", line 18, in panic<br>     channel.stop_consuming()<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>318, in stop_consuming<br>     self.basic_cancel(consumer_tag)<br>   File "/Users/christian/devel/pika/pika/channel.py", line 333, in <br>basic_cancel<br>     self._on_cancel_ok, [spec.Basic.CancelOk])<br>   File <br>"/Users/christian/devel/pika/pika/adapters/blocking_connection.py", line <br>209, in rpc<br>     self._on_rpc_complete)<br>TypeError: 'NoneType' object is not iterable<br><br><br>What I am doing wrong? Are the timeout callbacks not capable of stopping <br>the consumer?<br><br><br>Regards,<br>Christian<br>_______________________________________________<br>rabbitmq-discuss mailing list<br><a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br><a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>