Skip to content

Commit

Permalink
subprocess: Reintroduce conditional import
Browse files Browse the repository at this point in the history
  • Loading branch information
JukkaL committed Jul 11, 2013
1 parent 00e17e7 commit 8e25b89
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib-python/3.2/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,14 @@ class STARTUPINFO:
import fcntl
import pickle

import _posixsubprocess
try:
import _posixsubprocess
have_posixsubprocess = True
except ImportError:
have_posixsubprocess = False
warnings.warn("The _posixsubprocess module is not being used. "
"Child process reliability may suffer if your "
"program uses threads.", RuntimeWarning)

# When select or poll has indicated that the file is writable,
# we can write up to _PIPE_BUF bytes without risk of blocking.
Expand All @@ -398,7 +405,7 @@ def _set_cloexec(fd: int, cloexec: bool) -> None:
else:
fcntl.fcntl(fd, fcntl.F_SETFD, old & ~_FD_CLOEXEC)

if _posixsubprocess:
if have_posixsubprocess:
_create_pipe = _posixsubprocess.cloexec_pipe
else:
def __create_pipe() -> Tuple[int, int]:
Expand Down Expand Up @@ -1184,7 +1191,7 @@ def _execute_child(self, args: Sequence[str], executable: str,
try:
try:

if _posixsubprocess:
if have_posixsubprocess:
# We must avoid complex work that could involve
# malloc or free in the child process to avoid
# potential deadlocks, thus we do all this here.
Expand Down

0 comments on commit 8e25b89

Please sign in to comment.