Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daemon: don't use Popen on linux/mac #4262

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions dvc/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
def _spawn_windows(cmd, env):
from subprocess import STARTUPINFO, STARTF_USESHOWWINDOW

prefix = [sys.executable]
if not is_binary():
prefix += [sys.argv[0]]

creationflags = CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS

startupinfo = STARTUPINFO()
startupinfo.dwFlags |= STARTF_USESHOWWINDOW

Popen(
cmd,
prefix + cmd,
env=env,
close_fds=True,
shell=False,
Expand All @@ -34,6 +38,8 @@ def _spawn_windows(cmd, env):


def _spawn_posix(cmd, env):
from dvc.main import main

# NOTE: using os._exit instead of sys.exit, because dvc built
# with PyInstaller has trouble with SystemExit exception and throws
# errors such as "[26338] Failed to execute script __main__"
Expand All @@ -59,7 +65,8 @@ def _spawn_posix(cmd, env):
sys.stdout.close()
sys.stderr.close()

Popen(cmd, env=env, close_fds=True, shell=False).communicate()
os.environ.update(env)
main(cmd)

os._exit(0) # pylint: disable=protected-access

Expand Down Expand Up @@ -87,10 +94,7 @@ def daemon(args):
logger.debug("skipping launching a new daemon.")
return

cmd = [sys.executable]
if not is_binary():
cmd += [sys.argv[0]]
cmd += ["daemon", "-q"] + args
cmd = ["daemon", "-q"] + args

env = fix_env()
file_path = os.path.abspath(inspect.stack()[0][1])
Expand Down