Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Mirror
sjrpc
Commits
b00b7ee3
Commit
b00b7ee3
authored
Jan 31, 2011
by
Antoine Millet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better client disconnection handling.
parent
f41b6ab7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
sjrpc/server/simple.py
sjrpc/server/simple.py
+11
-12
No files found.
sjrpc/server/simple.py
View file @
b00b7ee3
...
...
@@ -41,8 +41,12 @@ class SimpleRpcServer(ConnectionManager):
connection
.
shutdown
(
self
.
_on_disconnect
)
self
.
_listening_sock
.
close
()
def
shutdown_client
(
self
,
connection
):
connection
.
shutdown
(
callback
=
self
.
_on_disconnect
)
def
shutdown_client
(
self
,
fd
):
conn
=
self
.
_clients
.
get
(
fd
)
self
.
_poll
.
unregister
(
fd
)
if
fd
is
not
None
:
del
self
.
_clients
[
fd
]
conn
.
shutdown
(
callback
=
self
.
_on_disconnect
)
def
all_connections
(
self
):
return
set
(
self
.
_clients
.
values
())
...
...
@@ -69,13 +73,11 @@ class SimpleRpcServer(ConnectionManager):
except
socket
.
error
as
err
:
logging
.
error
(
'Socket error while receiving from client '
'fd/%s: %s'
%
(
fd
,
err
))
connection
.
shutdown
(
self
.
_on_disconnect
)
del
self
.
_clients
[
fd
]
self
.
shutdown_client
(
fd
)
except
Exception
as
err
:
logging
.
error
(
'Unknown error while receiving from client '
'fd/%s: %s'
%
(
fd
,
err
))
connection
.
shutdown
(
self
.
_on_disconnect
)
del
self
.
_clients
[
fd
]
self
.
shutdown_client
(
fd
)
if
event
&
select
.
EPOLLOUT
:
# Data are ready to be written on socket
...
...
@@ -84,18 +86,15 @@ class SimpleRpcServer(ConnectionManager):
except
socket
.
error
as
err
:
logging
.
error
(
'Socket error while sending to the client '
'fd/%s: %s'
%
(
fd
,
err
))
connection
.
shutdown
(
self
.
_on_disconnect
)
del
self
.
_clients
[
fd
]
self
.
shutdown_client
(
fd
)
except
Exception
as
err
:
logging
.
error
(
'Unknown error while sending to the client '
'fd/%s: %s'
%
(
fd
,
err
))
connection
.
shutdown
(
self
.
_on_disconnect
)
del
self
.
_clients
[
fd
]
self
.
shutdown_client
(
fd
)
if
event
&
select
.
EPOLLHUP
:
logging
.
error
(
'Socket HUP fd/%s: %s'
%
(
fd
,
err
))
connection
.
shutdown
(
self
.
_on_disconnect
)
del
self
.
_clients
[
fd
]
self
.
shutdown_client
(
fd
)
class
SimpleSslRpcServer
(
SimpleRpcServer
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment