def _can_run(self): if self._used.is_set(): raise InvalidHandlerState("Receiver has already closed.") if self.receiver_shutdown: self.close() raise InvalidHandlerState("Receiver has already closed.") if not self.running: self.open()
def _mgmt_request_response(self, operation, message, callback, **kwargs): if not self.running: raise InvalidHandlerState("Client connection is closed.") try: application_properties = { ASSOCIATEDLINKPROPERTYNAME: self._handler.message_handler.name } except AttributeError: application_properties = {} mgmt_msg = Message(body=message, properties=MessageProperties( reply_to=self.mgmt_target, encoding=self.encoding, **kwargs), application_properties=application_properties) try: return self._handler.mgmt_request(mgmt_msg, operation, op_type=b"entity-mgmt", node=self.mgmt_target.encode( self.encoding), timeout=5000, callback=callback) except Exception as exp: # pylint: disable=broad-except raise ServiceBusError("Management request failed: {}".format(exp), exp)
async def _mgmt_request_response(self, operation, message, callback, **kwargs): if not self.running: raise InvalidHandlerState("Client connection is closed.") mgmt_msg = Message(body=message, properties=MessageProperties( reply_to=self.mgmt_target, encoding=self.encoding, **kwargs)) try: return await self._handler.mgmt_request_async( mgmt_msg, operation, op_type=b"entity-mgmt", node=self.mgmt_target.encode(self.encoding), timeout=5000, callback=callback) except Exception as exp: # pylint: disable=broad-except raise ServiceBusError("Management request failed: {}".format(exp), exp)