Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wspy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
wspy
Commits
09919006
Commit
09919006
authored
Nov 07, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WebSocket.receive_forever() now handles exceptions without crashing
parent
822bfe72
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
server.py
server.py
+3
-0
websocket.py
websocket.py
+13
-4
No files found.
server.py
View file @
09919006
...
...
@@ -87,6 +87,9 @@ class Client(WebSocket):
def
onclose
(
self
,
code
,
reason
):
self
.
server
.
remove_client
(
self
,
code
,
reason
)
def
onexception
(
self
,
e
):
logging
.
error
(
format_exc
(
e
))
def
__str__
(
self
):
return
'<Client at %s:%d>'
%
self
.
address
...
...
websocket.py
View file @
09919006
...
...
@@ -128,15 +128,18 @@ class WebSocket(object):
of multiple data frames, but this is not visible for onmessage().
Control messages (or control frames) are handled automatically.
"""
try
:
while
True
:
while
True
:
try
:
self
.
onmessage
(
self
,
self
.
receive_message
())
if
self
.
received_close_params
is
not
None
:
self
.
handle_close
(
*
self
.
received_close_params
)
break
except
SocketClosed
:
self
.
onclose
(
None
,
''
)
except
SocketClosed
:
self
.
onclose
(
None
,
''
)
break
except
Exception
as
e
:
self
.
onexception
(
e
)
def
run_threaded
(
self
,
daemon
=
True
):
"""
...
...
@@ -221,3 +224,9 @@ class WebSocket(object):
Called when the socket is closed by either end point.
"""
pass
def
onexception
(
self
,
e
):
"""
Handle a raised exception.
"""
pass
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