Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
1ea1dc9e
Commit
1ea1dc9e
authored
Jan 06, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify EpollEventManager.poll
parent
02763c9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
22 deletions
+16
-22
neo/lib/event.py
neo/lib/event.py
+16
-22
No files found.
neo/lib/event.py
View file @
1ea1dc9e
...
...
@@ -78,38 +78,32 @@ class EpollEventManager(object):
self
.
epoll
.
unregister
(
fd
)
del
self
.
connection_dict
[
fd
]
def
_getPendingConnection
(
self
):
if
self
.
_pending_processing
:
return
self
.
_pending_processing
.
pop
(
0
)
def
_addPendingConnection
(
self
,
conn
):
pending_processing
=
self
.
_pending_processing
if
conn
not
in
pending_processing
:
pending_processing
.
append
(
conn
)
def
poll
(
self
,
timeout
=
1
):
to_process
=
self
.
_getPendingConnection
()
if
to_process
is
None
:
if
not
self
.
_pending_processing
:
# Fetch messages from polled file descriptors
self
.
_poll
(
timeout
=
timeout
)
# See if there is anything to process
to_process
=
self
.
_getPendingConnection
()
if
to_process
is
not
None
:
to_process
.
lock
()
if
not
self
.
_pending_processing
:
return
to_process
=
self
.
_pending_processing
.
pop
(
0
)
to_process
.
lock
()
try
:
try
:
try
:
# Process
to_process
.
process
()
finally
:
# ...and requeue if there are pending messages
if
to_process
.
hasPendingMessages
():
self
.
_addPendingConnection
(
to_process
)
to_process
.
process
()
finally
:
to_process
.
unlock
()
# Non-blocking call: as we handled a packet, we should just offer
# poll a chance to fetch & send already-available data, but it must
# not delay us.
self
.
_poll
(
timeout
=
0
)
# ...and requeue if there are pending messages
if
to_process
.
hasPendingMessages
():
self
.
_addPendingConnection
(
to_process
)
finally
:
to_process
.
unlock
()
# Non-blocking call: as we handled a packet, we should just offer
# poll a chance to fetch & send already-available data, but it must
# not delay us.
self
.
_poll
(
timeout
=
0
)
def
_poll
(
self
,
timeout
=
1
):
try
:
...
...
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