Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
elif frame.reply_code == 503:
return exc.ConnectionCommandInvalid(frame.reply_text)
elif frame.reply_code == 504:
return exc.ConnectionChannelError(frame.reply_text)
elif frame.reply_code == 505:
return exc.ConnectionUnexpectedFrame(frame.reply_text)
elif frame.reply_code == 506:
return exc.ConnectionResourceError(frame.reply_text)
elif frame.reply_code == 530:
return exc.ConnectionNotAllowed(frame.reply_text)
elif frame.reply_code == 540:
return exc.ConnectionNotImplemented(frame.reply_text)
elif frame.reply_code == 541:
return exc.ConnectionInternalError(frame.reply_text)
else:
return exc.ConnectionClosed(frame.reply_code, frame.reply_text)
async def _on_close(self, ex=exc.ConnectionClosed(0, "normal closed")):
frame = (
spec.Connection.CloseOk()
if isinstance(ex, exc.ConnectionClosed)
else spec.Connection.Close()
)
await asyncio.gather(
self.__rpc(frame, wait_response=False), return_exceptions=True
)
writer = self.writer
self.reader = None
self.writer = None
self._reader_task = None
await asyncio.gather(
class ConnectionNotAllowed(ConnectionClosed):
reason = (
"The client tried to work with some entity in a manner that is "
"prohibited by the server, due to security settings or by "
"some other criteria: %r"
)
class ConnectionNotImplemented(ConnectionClosed):
reason = (
"The client tried to use functionality that is "
"not implemented in the server: %r"
)
class ConnectionInternalError(ConnectionClosed):
reason = (
" The server could not complete the method because of an "
"internal error. The server may require intervention by an "
"operator in order to resume normal operations: %r"
)
class AMQPChannelError(AMQPError):
reason = "An unspecified AMQP channel error has occurred"
class ChannelClosed(AMQPChannelError):
reason = "The channel was closed (%s) %s"
class ChannelAccessRefused(ChannelClosed):
reason = (
"The sender sent a frame that contained illegal values for "
"one or more fields. This strongly implies a programming error "
"in the sending peer: %r"
)
class ConnectionFrameError(ConnectionClosed):
reason = (
"The sender sent a malformed frame that the recipient could "
"not decode. This strongly implies a programming error "
"in the sending peer: %r"
)
class ConnectionCommandInvalid(ConnectionClosed):
reason = (
"The client sent an invalid sequence of frames, attempting to "
"perform an operation that was considered invalid by the server."
" This usually implies a programming error in the client: %r"
)
class ConnectionChannelError(ConnectionClosed):
reason = (
"The client attempted to work with a channel that had not been "
"correctly opened. This most likely indicates a fault in the "
"client layer: %r"
)
class ConnectionUnexpectedFrame(ConnectionClosed):
async def _on_close(self, ex=exc.ConnectionClosed(0, "normal closed")):
frame = (
spec.Connection.CloseOk()
if isinstance(ex, exc.ConnectionClosed)
else spec.Connection.Close()
)
await asyncio.gather(
self.__rpc(frame, wait_response=False), return_exceptions=True
)
writer = self.writer
self.reader = None
self.writer = None
self._reader_task = None
await asyncio.gather(
self.__close_writer(writer), return_exceptions=True
)
reason = (
"The server could not complete the method because it lacked "
"sufficient resources. This may be due to the client creating "
"too many of some type of entity: %r"
)
class ConnectionNotAllowed(ConnectionClosed):
reason = (
"The client tried to work with some entity in a manner that is "
"prohibited by the server, due to security settings or by "
"some other criteria: %r"
)
class ConnectionNotImplemented(ConnectionClosed):
reason = (
"The client tried to use functionality that is "
"not implemented in the server: %r"
)
class ConnectionInternalError(ConnectionClosed):
reason = (
" The server could not complete the method because of an "
"internal error. The server may require intervention by an "
"operator in order to resume normal operations: %r"
)
class AMQPChannelError(AMQPError):
reason = "An unspecified AMQP channel error has occurred"
async def __rpc(self, request: spec.Frame, wait_response=True):
self.writer.write(pamqp.frame.marshal(request, 0))
if not wait_response:
return
_, _, frame = await self.__receive_frame()
if request.synchronous and frame.name not in request.valid_responses:
raise spec.AMQPInternalError(frame, dict(frame))
elif isinstance(frame, spec.Connection.Close):
if frame.reply_code == 403:
err = exc.ProbableAuthenticationError(frame.reply_text)
else:
err = exc.ConnectionClosed(frame.reply_code, frame.reply_text)
await self.close(err)
raise err
return frame
"but client supports only %r."
)
class ProbableAuthenticationError(AMQPConnectionError):
reason = (
"Client was disconnected at a connection stage indicating a "
"probable authentication error: %s"
)
class ConnectionClosed(AMQPConnectionError):
reason = "The AMQP connection was closed (%s) %s"
class ConnectionSyntaxError(ConnectionClosed):
reason = (
"The sender sent a frame that contained illegal values for "
"one or more fields. This strongly implies a programming error "
"in the sending peer: %r"
)
class ConnectionFrameError(ConnectionClosed):
reason = (
"The sender sent a malformed frame that the recipient could "
"not decode. This strongly implies a programming error "
"in the sending peer: %r"
)
class ConnectionCommandInvalid(ConnectionClosed):
reason = (
"The client attempted to work with a channel that had not been "
"correctly opened. This most likely indicates a fault in the "
"client layer: %r"
)
class ConnectionUnexpectedFrame(ConnectionClosed):
reason = (
"The peer sent a frame that was not expected, usually in the "
"context of a content header and body. This strongly indicates "
"a fault in the peer's content processing: %r"
)
class ConnectionResourceError(ConnectionClosed):
reason = (
"The server could not complete the method because it lacked "
"sufficient resources. This may be due to the client creating "
"too many of some type of entity: %r"
)
class ConnectionNotAllowed(ConnectionClosed):
reason = (
"The client tried to work with some entity in a manner that is "
"prohibited by the server, due to security settings or by "
"some other criteria: %r"
)
class ConnectionNotImplemented(ConnectionClosed):