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
76d1e667
Commit
76d1e667
authored
Sep 21, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fakessh: use decorators rather than call_with_deadline(with_context=..)
parent
e4c83268
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
mitogen/fakessh.py
mitogen/fakessh.py
+12
-9
No files found.
mitogen/fakessh.py
View file @
76d1e667
...
...
@@ -215,21 +215,22 @@ class Process(object):
pass
def
_start_slave
(
mitogen_
,
src_id
,
args
):
@
mitogen
.
core
.
takes_router
def
_start_slave
(
src_id
,
args
,
router
):
"""
This runs in the target context, it is invoked by _fakessh_main running in
the fakessh context immediately after startup. It starts the slave process
(the the point where it has a stdin_handle to target but not stdout_chan to
write to), and waits for main to.
"""
LOG
.
debug
(
'_start_slave(%r, %r)'
,
mitogen_
,
args
)
LOG
.
debug
(
'_start_slave(%r, %r)'
,
router
,
args
)
proc
=
subprocess
.
Popen
(
args
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
)
process
=
Process
(
mitogen_
.
router
,
process
=
Process
(
router
,
proc
.
stdin
.
fileno
(),
proc
.
stdout
.
fileno
(),
proc
,
...
...
@@ -276,7 +277,8 @@ def parse_args():
return
hostname
,
allopts
,
args
def
_fakessh_main
(
mitogen_
,
dest_context_id
):
@
mitogen
.
core
.
takes_econtext
def
_fakessh_main
(
dest_context_id
,
econtext
):
hostname
,
opts
,
args
=
parse_args
()
if
not
hostname
:
die
(
'Missing hostname'
)
...
...
@@ -295,14 +297,15 @@ def _fakessh_main(mitogen_, dest_context_id):
if
subsystem
:
die
(
'-s <subsystem> is not yet supported'
)
dest
=
mitogen
.
master
.
Context
(
mitogen_
.
router
,
dest_context_id
)
control_handle
,
stdin_handle
=
dest
.
call_with_deadline
(
None
,
True
,
_start_slave
,
mitogen
.
context_id
,
args
)
dest
=
mitogen
.
master
.
Context
(
econtext
.
router
,
dest_context_id
)
control_handle
,
stdin_handle
=
dest
.
call
(
_start_slave
,
mitogen
.
context_id
,
args
)
LOG
.
debug
(
'_fakessh_main: received control_handle=%r, stdin_handle=%r'
,
control_handle
,
stdin_handle
)
process
=
Process
(
mitogen_
.
router
,
1
,
0
)
process
=
Process
(
econtext
.
router
,
1
,
0
)
process
.
start_master
(
stdin
=
mitogen
.
core
.
Sender
(
dest
,
stdin_handle
),
control
=
mitogen
.
core
.
Sender
(
dest
,
control_handle
),
...
...
@@ -352,7 +355,7 @@ def run(dest, router, args, deadline=None, econtext=None):
router
.
register
(
fakessh
,
stream
)
# Held in socket buffer until process is booted.
fakessh
.
call_async
(
True
,
_fakessh_main
,
dest
.
context_id
)
fakessh
.
call_async
(
_fakessh_main
,
dest
.
context_id
)
tmp_path
=
tempfile
.
mkdtemp
(
prefix
=
'mitogen_fakessh'
)
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