Fix some subprocess issues

This commit is contained in:
Dave Halter
2020-07-02 18:39:24 +02:00
parent 806ad06d6a
commit 92af043906
2 changed files with 1 additions and 14 deletions

View File

@@ -4,8 +4,6 @@ different Python versions.
""" """
import errno import errno
import sys import sys
import os
import subprocess
import pickle import pickle

View File

@@ -11,8 +11,6 @@ import os
import sys import sys
import queue import queue
import subprocess import subprocess
import socket
import errno
import traceback import traceback
import weakref import weakref
from functools import partial from functools import partial
@@ -206,9 +204,6 @@ class CompiledSubprocess(object):
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
# Use system default buffering on Python 2 to improve performance
# (this is already the case on Python 3).
bufsize=-1,
env=self._env_vars env=self._env_vars
) )
self._stderr_queue = queue.Queue() self._stderr_queue = queue.Queue()
@@ -253,13 +248,7 @@ class CompiledSubprocess(object):
data = inference_state_id, function, args, kwargs data = inference_state_id, function, args, kwargs
try: try:
pickle_dump(data, self._get_process().stdin, PICKLE_PROTOCOL) pickle_dump(data, self._get_process().stdin, PICKLE_PROTOCOL)
except (socket.error, IOError) as e: except BrokenPipeError:
# Once Python2 will be removed we can just use `BrokenPipeError`.
# Also, somehow in windows it returns EINVAL instead of EPIPE if
# the subprocess dies.
if e.errno not in (errno.EPIPE, errno.EINVAL):
# Not a broken pipe
raise
self._kill() self._kill()
raise InternalError("The subprocess %s was killed. Maybe out of memory?" raise InternalError("The subprocess %s was killed. Maybe out of memory?"
% self._executable) % self._executable)