mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-19 23:09:43 +08:00
Move GeneralizedPopen
This commit is contained in:
@@ -48,18 +48,3 @@ def pickle_dump(data, file, protocol):
|
|||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
raise IOError(errno.EPIPE, "Broken pipe")
|
raise IOError(errno.EPIPE, "Broken pipe")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
class GeneralizedPopen(subprocess.Popen):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
if os.name == 'nt':
|
|
||||||
try:
|
|
||||||
# Was introduced in Python 3.7.
|
|
||||||
CREATE_NO_WINDOW = subprocess.CREATE_NO_WINDOW
|
|
||||||
except AttributeError:
|
|
||||||
CREATE_NO_WINDOW = 0x08000000
|
|
||||||
kwargs['creationflags'] = CREATE_NO_WINDOW
|
|
||||||
# The child process doesn't need file descriptors except 0, 1, 2.
|
|
||||||
# This is unix only.
|
|
||||||
kwargs['close_fds'] = 'posix' in sys.builtin_module_names
|
|
||||||
super(GeneralizedPopen, self).__init__(*args, **kwargs)
|
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ import weakref
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from jedi._compatibility import \
|
from jedi._compatibility import pickle_dump, pickle_load
|
||||||
pickle_dump, pickle_load, GeneralizedPopen
|
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi.cache import memoize_method
|
from jedi.cache import memoize_method
|
||||||
from jedi.inference.compiled.subprocess import functions
|
from jedi.inference.compiled.subprocess import functions
|
||||||
@@ -32,6 +31,21 @@ _MAIN_PATH = os.path.join(os.path.dirname(__file__), '__main__.py')
|
|||||||
PICKLE_PROTOCOL = 4
|
PICKLE_PROTOCOL = 4
|
||||||
|
|
||||||
|
|
||||||
|
class _GeneralizedPopen(subprocess.Popen):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
if os.name == 'nt':
|
||||||
|
try:
|
||||||
|
# Was introduced in Python 3.7.
|
||||||
|
CREATE_NO_WINDOW = subprocess.CREATE_NO_WINDOW
|
||||||
|
except AttributeError:
|
||||||
|
CREATE_NO_WINDOW = 0x08000000
|
||||||
|
kwargs['creationflags'] = CREATE_NO_WINDOW
|
||||||
|
# The child process doesn't need file descriptors except 0, 1, 2.
|
||||||
|
# This is unix only.
|
||||||
|
kwargs['close_fds'] = 'posix' in sys.builtin_module_names
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def _enqueue_output(out, queue_):
|
def _enqueue_output(out, queue_):
|
||||||
for line in iter(out.readline, b''):
|
for line in iter(out.readline, b''):
|
||||||
queue_.put(line)
|
queue_.put(line)
|
||||||
@@ -187,7 +201,7 @@ class CompiledSubprocess(object):
|
|||||||
os.path.dirname(os.path.dirname(parso_path)),
|
os.path.dirname(os.path.dirname(parso_path)),
|
||||||
'.'.join(str(x) for x in sys.version_info[:3]),
|
'.'.join(str(x) for x in sys.version_info[:3]),
|
||||||
)
|
)
|
||||||
process = GeneralizedPopen(
|
process = _GeneralizedPopen(
|
||||||
args,
|
args,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
|||||||
Reference in New Issue
Block a user