Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sjrpc
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
sjrpc
Commits
f4b653ff
Commit
f4b653ff
authored
13 years ago
by
Antoine Millet
Browse files
Options
Downloads
Patches
Plain Diff
Now raise an exception when protocols are used in fallback mode
parent
9151bf7f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sjrpc/core/exceptions.py
+8
-0
8 additions, 0 deletions
sjrpc/core/exceptions.py
sjrpc/core/rpcconnection.py
+11
-1
11 additions, 1 deletion
sjrpc/core/rpcconnection.py
with
19 additions
and
1 deletion
sjrpc/core/exceptions.py
+
8
−
0
View file @
f4b653ff
...
...
@@ -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.
'''
This diff is collapsed.
Click to expand it.
sjrpc/core/rpcconnection.py
+
11
−
1
View file @
f4b653ff
...
...
@@ -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
...
...
@@ -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
()
...
...
@@ -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
:
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment