Loading sjrpc/core/exceptions.py +8 −0 Original line number Diff line number Diff line Loading @@ -31,3 +31,11 @@ class NoFreeLabelError(Exception): Exception raised when no more free labels are available for protocol allocation. ''' class FallbackModeEnabledError(Exception): ''' Exception raised when a feature which is not compatible with fallback mode is used. ''' sjrpc/core/rpcconnection.py +11 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,8 @@ import socket import logging from sjrpc.core.protocols import Protocol, RpcProtocol, TunnelProtocol from sjrpc.core.exceptions import RpcError, NoFreeLabelError from sjrpc.core.exceptions import (RpcError, NoFreeLabelError, FallbackModeEnabledError) import pyev Loading Loading @@ -62,6 +63,9 @@ class RpcConnection(object): self._sock = sock sock.setblocking(False) # Initialization requires fallback mode disabled: self.fallback = False # Get the pyev loop: if loop is None: self.loop = pyev.default_loop() Loading Loading @@ -294,6 +298,9 @@ class RpcConnection(object): ''' Register a new protocol for the specified label. ''' if self.fallback: raise FallbackModeEnabledError('Fallback mode is not compatible ' 'with protocols') if label is None: for label in xrange(0, RpcConnection.MAX_LABEL): if label not in self._protocols: Loading @@ -312,6 +319,9 @@ class RpcConnection(object): Unregister the specified protocol label for this connection. ''' if self.fallback: raise FallbackModeEnabledError('Fallback mode is not compatible ' 'with protocols') if label in self._protocols and label != 0: del self._protocols[label] else: Loading Loading
sjrpc/core/exceptions.py +8 −0 Original line number Diff line number Diff line Loading @@ -31,3 +31,11 @@ class NoFreeLabelError(Exception): Exception raised when no more free labels are available for protocol allocation. ''' class FallbackModeEnabledError(Exception): ''' Exception raised when a feature which is not compatible with fallback mode is used. '''
sjrpc/core/rpcconnection.py +11 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,8 @@ import socket import logging from sjrpc.core.protocols import Protocol, RpcProtocol, TunnelProtocol from sjrpc.core.exceptions import RpcError, NoFreeLabelError from sjrpc.core.exceptions import (RpcError, NoFreeLabelError, FallbackModeEnabledError) import pyev Loading Loading @@ -62,6 +63,9 @@ class RpcConnection(object): self._sock = sock sock.setblocking(False) # Initialization requires fallback mode disabled: self.fallback = False # Get the pyev loop: if loop is None: self.loop = pyev.default_loop() Loading Loading @@ -294,6 +298,9 @@ class RpcConnection(object): ''' Register a new protocol for the specified label. ''' if self.fallback: raise FallbackModeEnabledError('Fallback mode is not compatible ' 'with protocols') if label is None: for label in xrange(0, RpcConnection.MAX_LABEL): if label not in self._protocols: Loading @@ -312,6 +319,9 @@ class RpcConnection(object): Unregister the specified protocol label for this connection. ''' if self.fallback: raise FallbackModeEnabledError('Fallback mode is not compatible ' 'with protocols') if label in self._protocols and label != 0: del self._protocols[label] else: Loading