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
f241eac5
Commit
f241eac5
authored
Mar 18, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent: allow Python to determine its install prefix from argv[0]
Fixes support for virtualenv. Closes #152.
parent
088fd761
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
+14
-5
docs/api.rst
docs/api.rst
+5
-0
docs/index.rst
docs/index.rst
+1
-1
mitogen/parent.py
mitogen/parent.py
+8
-4
No files found.
docs/api.rst
View file @
f241eac5
...
...
@@ -525,6 +525,11 @@ Router Class
If unspecified, defaults to ``<username>@<hostname>:<pid>``.
This variable cannot contain slash characters, as the resulting
``argv[0]`` must be presented in such a way as to allow Python to
determine its installation prefix. This is required to support
virtualenv.
:param str python_path:
Path to the Python interpreter to use for bootstrap. Defaults to
``python2.7``. In future this may default to ``sys.executable``.
...
...
docs/index.rst
View file @
f241eac5
...
...
@@ -68,7 +68,7 @@ using the UNIX **ps** command:
20051 ? Ss 0:00 \_ sshd: dmw [priv]
20053 ? S 0:00 | \_ sshd: dmw@notty
20054 ? Ssl 0:00 | \_
mitogen:dmw@Eldil.home:22476
20054 ? Ssl 0:00 | \_
/usr/bin/python(mitogen:dmw@Eldil.home:22476)
20103 ? S 0:00 | \_ tar zxvf myapp.tar.gz
The example context was started by UID ``dmw`` on host ``Eldil.home``, process
...
...
mitogen/parent.py
View file @
f241eac5
...
...
@@ -313,6 +313,8 @@ class Stream(mitogen.core.Stream):
if
remote_name
is
None
:
remote_name
=
'%s@%s:%d'
remote_name
%=
(
getpass
.
getuser
(),
socket
.
gethostname
(),
os
.
getpid
())
if
'/'
in
remote_name
or
'
\
\
'
in
remote_name
:
raise
ValueError
(
'remote_name= cannot contain slashes'
)
self
.
remote_name
=
remote_name
self
.
debug
=
debug
self
.
profiling
=
profiling
...
...
@@ -332,9 +334,11 @@ class Stream(mitogen.core.Stream):
# Minimised, gzipped, base64'd and passed to 'python -c'. It forks, dups
# file descriptor 0 as 100, creates a pipe, then execs a new interpreter
# with a custom argv.
# 'CONTEXT_NAME', 'PREAMBLE_COMPRESSED_LEN', and 'PREAMBLE_LEN' are
# * Optimized for minimum byte count after minification & compression.
# * 'CONTEXT_NAME', 'PREAMBLE_COMPRESSED_LEN', and 'PREAMBLE_LEN' are
# substituted with their respective values.
# Optimized for minimum byte count after minification & compression.
# * CONTEXT_NAME must be prefixed with the name of the Python binary in
# order to allow virtualenvs to detect their install prefix.
@
staticmethod
def
_first_stage
():
R
,
W
=
os
.
pipe
()
...
...
@@ -348,7 +352,7 @@ class Stream(mitogen.core.Stream):
os
.
close
(
W
)
os
.
close
(
w
)
os
.
environ
[
'ARGV0'
]
=
sys
.
executable
os
.
execl
(
sys
.
executable
,
'mitogen:CONTEXT_NAME
'
)
os
.
execl
(
sys
.
executable
,
sys
.
executable
+
'(mitogen:CONTEXT_NAME)
'
)
os
.
write
(
1
,
'EC0
\
n
'
)
C
=
_
(
os
.
fdopen
(
0
,
'rb'
).
read
(
PREAMBLE_COMPRESSED_LEN
),
'zip'
)
os
.
fdopen
(
W
,
'w'
,
0
).
write
(
C
)
...
...
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