Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
4f50707b
Commit
4f50707b
authored
Sep 17, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: support takes_econtext and takes_router decorators.
parent
3a0f0318
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
0 deletions
+37
-0
docs/api.rst
docs/api.rst
+22
-0
mitogen/core.py
mitogen/core.py
+14
-0
mitogen/fakessh.py
mitogen/fakessh.py
+1
-0
No files found.
docs/api.rst
View file @
4f50707b
...
@@ -22,6 +22,28 @@ mitogen.core
...
@@ -22,6 +22,28 @@ mitogen.core
.. automodule:: mitogen.core
.. automodule:: mitogen.core
.. function:: mitogen.core.takes_econtext
Decorator that marks a function or class method to automatically receive a
kwarg named `econtext`, referencing the
:py:class:`econtext.core.ExternalContext` active in the context in which
the function is being invoked in. The decorator is only meaningful when the
function is invoked via :py:data:`econtext.core.CALL_FUNCTION`.
When the function is invoked directly, `econtext` must still be passed to it
explicitly.
.. function:: mitogen.core.takes_router
Decorator that marks a function or class method to automatically receive a
kwarg named `router`, referencing the :py:class:`econtext.core.Router`
active in the context in which the function is being invoked in. The
decorator is only meaningful when the function is invoked via
:py:data:`econtext.core.CALL_FUNCTION`.
When the function is invoked directly, `router` must still be passed to it
explicitly.
mitogen.master
mitogen.master
--------------
--------------
...
...
mitogen/core.py
View file @
4f50707b
...
@@ -117,6 +117,16 @@ def fire(obj, name, *args, **kwargs):
...
@@ -117,6 +117,16 @@ def fire(obj, name, *args, **kwargs):
return
[
func
(
*
args
,
**
kwargs
)
for
func
in
signals
.
get
(
name
,
())]
return
[
func
(
*
args
,
**
kwargs
)
for
func
in
signals
.
get
(
name
,
())]
def
takes_econtext
(
func
):
func
.
mitogen_takes_econtext
=
True
return
func
def
takes_router
(
func
):
func
.
mitogen_takes_router
=
True
return
func
def
set_cloexec
(
fd
):
def
set_cloexec
(
fd
):
flags
=
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
flags
=
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
fcntl
.
fcntl
(
fd
,
fcntl
.
F_SETFD
,
flags
|
fcntl
.
FD_CLOEXEC
)
fcntl
.
fcntl
(
fd
,
fcntl
.
F_SETFD
,
flags
|
fcntl
.
FD_CLOEXEC
)
...
@@ -1185,6 +1195,10 @@ class ExternalContext(object):
...
@@ -1185,6 +1195,10 @@ class ExternalContext(object):
if
klass
:
if
klass
:
obj
=
getattr
(
obj
,
klass
)
obj
=
getattr
(
obj
,
klass
)
fn
=
getattr
(
obj
,
func
)
fn
=
getattr
(
obj
,
func
)
if
getattr
(
fn
,
'mitogen_takes_econtext'
,
None
):
kwargs
.
setdefault
(
'econtext'
,
self
)
if
getattr
(
fn
,
'mitogen_takes_router'
,
None
):
kwargs
.
setdefault
(
'router'
,
self
.
router
)
ret
=
fn
(
*
args
,
**
kwargs
)
ret
=
fn
(
*
args
,
**
kwargs
)
self
.
router
.
route
(
self
.
router
.
route
(
Message
.
pickled
(
ret
,
dst_id
=
msg
.
src_id
,
handle
=
msg
.
reply_to
)
Message
.
pickled
(
ret
,
dst_id
=
msg
.
src_id
,
handle
=
msg
.
reply_to
)
...
...
mitogen/fakessh.py
View file @
4f50707b
...
@@ -311,6 +311,7 @@ def _fakessh_main(mitogen_, dest_context_id):
...
@@ -311,6 +311,7 @@ def _fakessh_main(mitogen_, dest_context_id):
# Public API.
# Public API.
#
#
@
mitogen
.
core
.
takes_router
def
run
(
dest
,
router
,
args
,
deadline
=
None
):
def
run
(
dest
,
router
,
args
,
deadline
=
None
):
"""
"""
Run the command specified by the argument vector `args` such that ``PATH``
Run the command specified by the argument vector `args` such that ``PATH``
...
...
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