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
a526a47e
Commit
a526a47e
authored
Dec 07, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make gevent.spawn_raw accept kwargs for consistency. Fixes #680.
parent
0ebe9d1e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
13 deletions
+43
-13
changelog.rst
changelog.rst
+4
-0
gevent/corecffi.py
gevent/corecffi.py
+1
-2
gevent/hub.py
gevent/hub.py
+25
-9
greentest/test__greenlet.py
greentest/test__greenlet.py
+11
-0
scripts/install.sh
scripts/install.sh
+2
-2
No files found.
changelog.rst
View file @
a526a47e
...
...
@@ -20,6 +20,10 @@
SIGCHLD signal at the process level (although this may allow race
conditions with libev child watchers). Reported in :issue:`696` by
Adam Ning.
- :func:`gevent.spawn_raw` now accepts keyword arguments, as
previously (incorrectly) documented. Reported in :issue:`680` by Ron
Rothman.
- PyPy: PyPy 2.6.1 or later is now required (4.0.1 or later is recommended).
1.1rc1 (Nov 14, 2015)
=====================
...
...
gevent/corecffi.py
View file @
a526a47e
...
...
@@ -518,9 +518,8 @@ class loop(object):
if
once
:
flags
|=
libev
.
EVRUN_ONCE
self
.
keyboard_interrupt_allowed
=
False
libev
.
ev_run
(
self
.
_ptr
,
flags
)
self
.
keyboard_interrupt_allowed
=
True
def
reinit
(
self
):
libev
.
ev_loop_fork
(
self
.
_ptr
)
...
...
gevent/hub.py
View file @
a526a47e
...
...
@@ -3,8 +3,9 @@
Event-loop hub.
"""
from
__future__
import
absolute_import
import
sys
from
functools
import
partial
as
_functools_partial
import
os
import
sys
import
traceback
from
greenlet
import
greenlet
,
getcurrent
,
GreenletExit
...
...
@@ -112,14 +113,20 @@ class ConcurrentObjectUseError(AssertionError):
pass
def
spawn_raw
(
function
,
*
args
):
def
spawn_raw
(
function
,
*
args
,
**
kwargs
):
"""
Create a new :class:`greenlet.greenlet` object and schedule it to run ``function(*args, **kwargs)``.
Create a new :class:`greenlet.greenlet` object and schedule it to
run ``function(*args, **kwargs)``.
This returns a raw :class:`~greenlet.greenlet` which does not have all the useful
methods that :class:`gevent.Greenlet` has. Typically, applications
should prefer :func:`~gevent.spawn`, but this method may
occasionally be useful as an optimization if there are many
greenlets involved.
This returns a raw greenlet which does not have all the useful methods that
:class:`gevent.Greenlet` has. Typically, applications should prefer :func:`gevent.spawn`,
but this method may occasionally be useful as an optimization if there are many greenlets
involved.
.. versionchanged:: 1.1rc2
Accept keyword arguments for ``function`` as previously (incorrectly)
documented. Note that this may incur an additional expense.
.. versionchanged:: 1.1a3
Verify that ``function`` is callable, raising a TypeError if not. Previously,
...
...
@@ -128,8 +135,17 @@ def spawn_raw(function, *args):
if
not
callable
(
function
):
raise
TypeError
(
"function must be callable"
)
hub
=
get_hub
()
g
=
greenlet
(
function
,
hub
)
hub
.
loop
.
run_callback
(
g
.
switch
,
*
args
)
# The callback class object that we use to run this doesn't
# accept kwargs (and those objects are heavily used, as well as being
# implemented twice in core.ppyx and corecffi.py) so do it with a partial
if
kwargs
:
function
=
_functools_partial
(
function
,
*
args
,
**
kwargs
)
g
=
greenlet
(
function
,
hub
)
hub
.
loop
.
run_callback
(
g
.
switch
)
else
:
g
=
greenlet
(
function
,
hub
)
hub
.
loop
.
run_callback
(
g
.
switch
,
*
args
)
return
g
...
...
greentest/test__greenlet.py
View file @
a526a47e
...
...
@@ -485,6 +485,17 @@ class TestBasic(greentest.TestCase):
# Passing both, but not implemented
self
.
assertRaises
(
TypeError
,
gevent
.
spawn_later
,
1
,
1
)
def
test_spawn_raw_kwargs
(
self
):
value
=
[]
def
f
(
*
args
,
**
kwargs
):
value
.
append
(
args
)
value
.
append
(
kwargs
)
g
=
gevent
.
spawn_raw
(
f
,
1
,
name
=
'value'
)
gevent
.
sleep
(
0.01
)
self
.
assertEqual
(
value
[
0
],
(
1
,))
self
.
assertEqual
(
value
[
1
],
{
'name'
:
'value'
})
def
test_simple_exit
(
self
):
link_test
=
[]
...
...
scripts/install.sh
View file @
a526a47e
...
...
@@ -85,7 +85,7 @@ for var in "$@"; do
install
2.6.9 python2.6
;;
2.7
)
install
2.7.
9
python2.7
install
2.7.
11
python2.7
;;
3.2
)
install
3.2.6 python3.2
...
...
@@ -97,7 +97,7 @@ for var in "$@"; do
install
3.4.3 python3.4
;;
3.5
)
install
3.5.
0
python3.5
install
3.5.
1
python3.5
;;
pypy
)
install
pypy-4.0.1 pypy
...
...
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