Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Iliya Manolov
neoppod
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):
...
@@ -78,38 +78,32 @@ class EpollEventManager(object):
self
.
epoll
.
unregister
(
fd
)
self
.
epoll
.
unregister
(
fd
)
del
self
.
connection_dict
[
fd
]
del
self
.
connection_dict
[
fd
]
def
_getPendingConnection
(
self
):
if
self
.
_pending_processing
:
return
self
.
_pending_processing
.
pop
(
0
)
def
_addPendingConnection
(
self
,
conn
):
def
_addPendingConnection
(
self
,
conn
):
pending_processing
=
self
.
_pending_processing
pending_processing
=
self
.
_pending_processing
if
conn
not
in
pending_processing
:
if
conn
not
in
pending_processing
:
pending_processing
.
append
(
conn
)
pending_processing
.
append
(
conn
)
def
poll
(
self
,
timeout
=
1
):
def
poll
(
self
,
timeout
=
1
):
to_process
=
self
.
_getPendingConnection
()
if
not
self
.
_pending_processing
:
if
to_process
is
None
:
# Fetch messages from polled file descriptors
# Fetch messages from polled file descriptors
self
.
_poll
(
timeout
=
timeout
)
self
.
_poll
(
timeout
=
timeout
)
# See if there is anything to process
if
not
self
.
_pending_processing
:
to_process
=
self
.
_getPendingConnection
()
return
if
to_process
is
not
None
:
to_process
=
self
.
_pending_processing
.
pop
(
0
)
to_process
.
lock
()
to_process
.
lock
()
try
:
try
:
try
:
try
:
to_process
.
process
()
# Process
to_process
.
process
()
finally
:
# ...and requeue if there are pending messages
if
to_process
.
hasPendingMessages
():
self
.
_addPendingConnection
(
to_process
)
finally
:
finally
:
to_process
.
unlock
()
# ...and requeue if there are pending messages
# Non-blocking call: as we handled a packet, we should just offer
if
to_process
.
hasPendingMessages
():
# poll a chance to fetch & send already-available data, but it must
self
.
_addPendingConnection
(
to_process
)
# not delay us.
finally
:
self
.
_poll
(
timeout
=
0
)
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
):
def
_poll
(
self
,
timeout
=
1
):
try
:
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