kind of new to Pika, i have some code like:(not include constructor and other unrelated function here)
class Consumer(object):
def __disconnect(self):
try:
self.__channel.stop_consuming()
self.__channel.close()
self.__connection.close()
except Exception as e:
print str(e)
def run(self):
While self.__isConsuming:
self.__channel.start_consuming()
print('stop consuming')
def shutdown(self):
self.__isConsuming=False
self.__disconnect()
print('complete')
this is in a seperate consuming thread. But when I call the shutdown consumer from the thread, sometimes it hit the exception in disconnect function saying connection already closed then I will see the print in shutdown; sometimes it just hit the print in run and exit from run and never saw the print in shutdown which seems an incomplete shutdown to me.
So anyone knows the reason? And what should be the proper way to shutdown a pika consumer thread? BTW, I am using pika blockingConnection
Thanks