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
870e8e13
Commit
870e8e13
authored
Mar 26, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Greenlet can cimport waiter.
parent
cdac6316
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
11 deletions
+17
-11
src/gevent/_greenlet.pxd
src/gevent/_greenlet.pxd
+6
-1
src/gevent/greenlet.py
src/gevent/greenlet.py
+5
-5
src/gevent/hub.py
src/gevent/hub.py
+6
-5
No files found.
src/gevent/_greenlet.pxd
View file @
870e8e13
...
@@ -3,10 +3,12 @@
...
@@ -3,10 +3,12 @@
cimport
cython
cimport
cython
from
gevent.__ident
cimport
IdentRegistry
from
gevent.__ident
cimport
IdentRegistry
from
gevent.__hub_local
cimport
get_hub_noargs
as
get_hub
from
gevent.__hub_local
cimport
get_hub_noargs
as
get_hub
cdef
bint
_greenlet_imported
from
gevent.__waiter
cimport
Waiter
cdef
bint
_PYPY
cdef
bint
_PYPY
cdef
sys_getframe
cdef
sys_getframe
cdef
sys_exc_info
cdef
sys_exc_info
cdef
Timeout
cdef
extern
from
"greenlet/greenlet.h"
:
cdef
extern
from
"greenlet/greenlet.h"
:
...
@@ -19,9 +21,12 @@ cdef extern from "greenlet/greenlet.h":
...
@@ -19,9 +21,12 @@ cdef extern from "greenlet/greenlet.h":
greenlet
PyGreenlet_GetCurrent
()
greenlet
PyGreenlet_GetCurrent
()
void
PyGreenlet_Import
()
void
PyGreenlet_Import
()
@
cython
.
final
cdef
inline
greenlet
getcurrent
():
cdef
inline
greenlet
getcurrent
():
return
PyGreenlet_GetCurrent
()
return
PyGreenlet_GetCurrent
()
cdef
bint
_greenlet_imported
cdef
inline
void
greenlet_init
():
cdef
inline
void
greenlet_init
():
global
_greenlet_imported
global
_greenlet_imported
if
not
_greenlet_imported
:
if
not
_greenlet_imported
:
...
...
src/gevent/greenlet.py
View file @
870e8e13
...
@@ -17,7 +17,6 @@ from gevent._tblib import load_traceback
...
@@ -17,7 +17,6 @@ from gevent._tblib import load_traceback
from
gevent.hub
import
GreenletExit
from
gevent.hub
import
GreenletExit
from
gevent.hub
import
InvalidSwitchError
from
gevent.hub
import
InvalidSwitchError
from
gevent.hub
import
Waiter
from
gevent.hub
import
iwait
from
gevent.hub
import
iwait
from
gevent.hub
import
wait
from
gevent.hub
import
wait
...
@@ -27,6 +26,8 @@ from gevent._config import config as GEVENT_CONFIG
...
@@ -27,6 +26,8 @@ from gevent._config import config as GEVENT_CONFIG
from
gevent._util
import
Lazy
from
gevent._util
import
Lazy
from
gevent._util
import
readproperty
from
gevent._util
import
readproperty
from
gevent._hub_local
import
get_hub_noargs
as
get_hub
from
gevent._hub_local
import
get_hub_noargs
as
get_hub
from
gevent
import
_waiter
__all__
=
[
__all__
=
[
'Greenlet'
,
'Greenlet'
,
...
@@ -35,14 +36,13 @@ __all__ = [
...
@@ -35,14 +36,13 @@ __all__ = [
]
]
# In Cython, we define these as 'cdef inline' functions. The
# In Cython, we define these as 'cdef inline' functions. The
# compilation unit cannot have a direct assignment to them (import
# compilation unit cannot have a direct assignment to them (import
# is assignment) without generating a 'lvalue is not valid target'
# is assignment) without generating a 'lvalue is not valid target'
# error.
# error.
locals
()[
'getcurrent'
]
=
__import__
(
'greenlet'
).
getcurrent
locals
()[
'getcurrent'
]
=
__import__
(
'greenlet'
).
getcurrent
locals
()[
'greenlet_init'
]
=
lambda
:
None
locals
()[
'greenlet_init'
]
=
lambda
:
None
locals
()[
'Waiter'
]
=
_waiter
.
Waiter
if
_PYPY
:
if
_PYPY
:
...
@@ -638,7 +638,7 @@ class Greenlet(greenlet):
...
@@ -638,7 +638,7 @@ class Greenlet(greenlet):
if
self
.
dead
:
if
self
.
dead
:
self
.
__handle_death_before_start
((
exception
,))
self
.
__handle_death_before_start
((
exception
,))
else
:
else
:
waiter
=
Waiter
()
if
block
else
None
waiter
=
Waiter
()
if
block
else
None
# pylint:disable=undefined-variable
self
.
parent
.
loop
.
run_callback
(
_kill
,
self
,
exception
,
waiter
)
self
.
parent
.
loop
.
run_callback
(
_kill
,
self
,
exception
,
waiter
)
if
block
:
if
block
:
waiter
.
get
()
waiter
.
get
()
...
@@ -955,7 +955,7 @@ def killall(greenlets, exception=GreenletExit, block=True, timeout=None):
...
@@ -955,7 +955,7 @@ def killall(greenlets, exception=GreenletExit, block=True, timeout=None):
return
return
loop
=
greenlets
[
0
].
loop
loop
=
greenlets
[
0
].
loop
if
block
:
if
block
:
waiter
=
Waiter
()
waiter
=
Waiter
()
# pylint:disable=undefined-variable
loop
.
run_callback
(
_killall3
,
greenlets
,
exception
,
waiter
)
loop
.
run_callback
(
_killall3
,
greenlets
,
exception
,
waiter
)
t
=
Timeout
.
_start_new_or_dummy
(
timeout
)
t
=
Timeout
.
_start_new_or_dummy
(
timeout
)
try
:
try
:
...
...
src/gevent/hub.py
View file @
870e8e13
...
@@ -162,7 +162,7 @@ def sleep(seconds=0, ref=True):
...
@@ -162,7 +162,7 @@ def sleep(seconds=0, ref=True):
hub
=
_get_hub_noargs
()
hub
=
_get_hub_noargs
()
loop
=
hub
.
loop
loop
=
hub
.
loop
if
seconds
<=
0
:
if
seconds
<=
0
:
waiter
=
Waiter
()
waiter
=
Waiter
(
hub
)
loop
.
run_callback
(
waiter
.
switch
)
loop
.
run_callback
(
waiter
.
switch
)
waiter
.
get
()
waiter
.
get
()
else
:
else
:
...
@@ -672,7 +672,7 @@ class Hub(TrackedRawGreenlet):
...
@@ -672,7 +672,7 @@ class Hub(TrackedRawGreenlet):
if
self
.
dead
:
if
self
.
dead
:
return
True
return
True
waiter
=
Waiter
()
waiter
=
Waiter
(
self
)
if
timeout
is
not
None
:
if
timeout
is
not
None
:
timeout
=
self
.
loop
.
timer
(
timeout
,
ref
=
False
)
timeout
=
self
.
loop
.
timer
(
timeout
,
ref
=
False
)
...
@@ -782,16 +782,17 @@ def iwait(objects, timeout=None, count=None):
...
@@ -782,16 +782,17 @@ def iwait(objects, timeout=None, count=None):
in between items yielded by this function.
in between items yielded by this function.
"""
"""
# QQQ would be nice to support iterable here that can be generated slowly (why?)
# QQQ would be nice to support iterable here that can be generated slowly (why?)
hub
=
_get_hub_noargs
()
if
objects
is
None
:
if
objects
is
None
:
yield
_get_hub_noargs
()
.
join
(
timeout
=
timeout
)
yield
hub
.
join
(
timeout
=
timeout
)
return
return
count
=
len
(
objects
)
if
count
is
None
else
min
(
count
,
len
(
objects
))
count
=
len
(
objects
)
if
count
is
None
else
min
(
count
,
len
(
objects
))
waiter
=
_MultipleWaiter
()
waiter
=
_MultipleWaiter
(
hub
)
switch
=
waiter
.
switch
switch
=
waiter
.
switch
if
timeout
is
not
None
:
if
timeout
is
not
None
:
timer
=
_get_hub_noargs
()
.
loop
.
timer
(
timeout
,
priority
=-
1
)
timer
=
hub
.
loop
.
timer
(
timeout
,
priority
=-
1
)
timer
.
start
(
switch
,
_NONE
)
timer
.
start
(
switch
,
_NONE
)
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