#NEWLINE# @ contextmanager #NEWLINE# def connection( self ) : #NEWLINE# #INDENT# 'Returns a new connection as a context manager.' #NEWLINE# conn = amqp . Connection ( host = ( '%s:%s' % ( self . config . RABBIT_HOST , self . config . RABBIT_PORT ) ) , userid = self . config . RABBIT_USER , password = self . config . RABBIT_PASSWORD , virtual_host = self . config . RABBIT_VIRTUAL_HOST ) #NEWLINE# logger . info ( 'Connected to RabbitMQ' ) #NEWLINE# with closing ( conn ) : #NEWLINE# #INDENT# ( yield conn )