Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
90361d25
Commit
90361d25
authored
Jul 08, 2015
by
Eddi Linder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the original poll to receive all events on immediate return
parent
379839fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
gevent/select.py
gevent/select.py
+23
-3
No files found.
gevent/select.py
View file @
90361d25
...
...
@@ -5,6 +5,11 @@ from gevent.hub import get_hub
from
gevent.hub
import
integer_types
from
select
import
POLLIN
,
POLLOUT
try
:
from
select
import
poll
as
original_poll
except
ImportError
:
original_poll
=
None
__implements__
=
[
'select'
,
'poll'
]
__all__
=
[
'error'
]
+
__implements__
...
...
@@ -76,14 +81,14 @@ class PollResult(object):
__slots__
=
[
'events'
,
'event'
]
def
__init__
(
self
):
self
.
events
=
[]
self
.
events
=
set
()
self
.
event
=
Event
()
def
add_event
(
self
,
events
,
fd
):
result_flags
=
0
result_flags
|=
POLLIN
if
events
&
1
else
0
result_flags
|=
POLLOUT
if
events
&
2
else
0
self
.
events
.
a
ppen
d
((
fd
,
result_flags
))
self
.
events
.
a
d
d
((
fd
,
result_flags
))
self
.
event
.
set
()
...
...
@@ -91,6 +96,11 @@ class poll(object):
def
__init__
(
self
):
self
.
fds
=
{}
self
.
loop
=
get_hub
().
loop
# Using the original poll to handle immediate response polling.
# Using the ev based way, we receive a signal on the first descriptor.
self
.
poll_obj
=
None
if
original_poll
is
not
None
:
self
.
poll_obj
=
original_poll
()
def
register
(
self
,
fd
,
eventmask
=
POLLIN
|
POLLOUT
):
flags
=
0
...
...
@@ -99,11 +109,19 @@ class poll(object):
watcher
=
self
.
loop
.
io
(
get_fileno
(
fd
),
flags
)
watcher
.
priority
=
self
.
loop
.
MAXPRI
self
.
fds
[
fd
]
=
watcher
if
self
.
poll_obj
:
self
.
poll_obj
.
register
(
fd
,
eventmask
)
def
modify
(
self
,
fd
,
eventmask
):
self
.
register
(
fd
,
eventmask
)
if
self
.
poll_obj
:
self
.
poll_obj
.
modify
(
fd
,
eventmask
)
def
poll
(
self
,
timeout
=
None
):
if
self
.
poll_obj
:
results
=
self
.
poll_obj
.
poll
(
0
)
if
results
:
return
results
result
=
PollResult
()
try
:
for
fd
in
self
.
fds
:
...
...
@@ -111,10 +129,12 @@ class poll(object):
if
timeout
is
not
None
and
-
1
<
timeout
:
timeout
/=
1000.0
result
.
event
.
wait
(
timeout
=
timeout
)
return
result
.
events
return
list
(
result
.
events
)
finally
:
for
fd
in
self
.
fds
:
self
.
fds
[
fd
].
stop
()
def
unregister
(
self
,
fd
):
self
.
fds
.
pop
(
fd
,
None
)
if
self
.
poll_obj
:
self
.
poll_obj
.
unregister
(
fd
)
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