[文档]classConnection(bootsteps.StartStopStep):"""Service managing the consumer broker connection."""def__init__(self,c,**kwargs):c.connection=Nonesuper().__init__(c,**kwargs)
[文档]defstart(self,c):c.connection=c.connect()info('Connected to %s',c.connection.as_uri())
[文档]defshutdown(self,c):# We must set self.connection to None here, so# that the green pidbox thread exits.connection,c.connection=c.connection,Noneifconnection:ignore_errors(connection,connection.close)