Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
16559725
Commit
16559725
authored
12 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
failures on accept() resolved nicely
parent
ecf6a7d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
network/selectloop.py
+11
-5
11 additions, 5 deletions
network/selectloop.py
with
11 additions
and
5 deletions
network/selectloop.py
+
11
−
5
View file @
16559725
...
@@ -19,6 +19,8 @@ class SelectLoop(BaseThread):
...
@@ -19,6 +19,8 @@ class SelectLoop(BaseThread):
* select
'
s on the sockets, closing and removing failed ones as necessary
* select
'
s on the sockets, closing and removing failed ones as necessary
* dispatches on_read and on_write, accepts connections.
* dispatches on_read and on_write, accepts connections.
if those calls throw ConnectionFailedException, they will be closed
if those calls throw ConnectionFailedException, they will be closed
if you are doing something THAT fancy that server socket accept() may fail (eg. SSL), you have
to throw ConnectionFailedException in your on_accept() if that happens
- when terminated, invokes on_cleanup()
- when terminated, invokes on_cleanup()
- remaining client sockets are closed. Server socket is NOT CLOSED.
- remaining client sockets are closed. Server socket is NOT CLOSED.
...
@@ -45,7 +47,7 @@ class SelectLoop(BaseThread):
...
@@ -45,7 +47,7 @@ class SelectLoop(BaseThread):
@type sock: L{satella.network.socket.BaseSocket} descendants
"""
@type sock: L{satella.network.socket.BaseSocket} descendants
"""
self
.
external_accepts
.
put
(
sock
)
self
.
external_accepts
.
put
(
sock
)
def
on_accept
(
self
,
s
ocket
,
addr
):
def
on_accept
(
self
,
s
erver_socket
):
"""
"""
Override this.
Override this.
@param socket: raw socket object
@param socket: raw socket object
...
@@ -54,7 +56,7 @@ class SelectLoop(BaseThread):
...
@@ -54,7 +56,7 @@ class SelectLoop(BaseThread):
@return: new L{satella.network.socket.BaseSocket} or None, if socket is to be forgotten
@return: new L{satella.network.socket.BaseSocket} or None, if socket is to be forgotten
(it can be returned later by send_socket)
(it can be returned later by send_socket)
"""
"""
return
BaseSocket
(
s
ocket
)
return
BaseSocket
(
s
erver_socket
.
accept
()[
0
]
)
def
on_startup
(
self
):
def
on_startup
(
self
):
"""
Override this. Called before the loop starts iterating, in new thread-context
"""
"""
Override this. Called before the loop starts iterating, in new thread-context
"""
...
@@ -122,9 +124,13 @@ class SelectLoop(BaseThread):
...
@@ -122,9 +124,13 @@ class SelectLoop(BaseThread):
for
sock
in
rs
:
# analyze sockets ready to be read
for
sock
in
rs
:
# analyze sockets ready to be read
if
sock
==
self
.
server_socket
:
# accepting
if
sock
==
self
.
server_socket
:
# accepting
n_sock
=
self
.
on_accept
(
*
sock
.
accept
())
try
:
if
n_sock
!=
None
:
# socket returned
n_sock
=
self
.
on_accept
(
sock
)
self
.
client_sockets
.
append
(
n_sock
)
except
ConnectionFailedException
:
pass
else
:
if
n_sock
!=
None
:
# socket returned
self
.
client_sockets
.
append
(
n_sock
)
else
:
# just a civilian socket
else
:
# just a civilian socket
try
:
try
:
sock
.
on_read
()
sock
.
on_read
()
...
...
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