2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-29 05:03:34 +08:00

ctlmgr,worker: set PYTHONUNBUFFERED for subprocesses

This commit is contained in:
Sebastien Bourdeauducq 2016-02-18 12:41:08 +01:00
parent ca3cced0b4
commit 155c2ec2ef
2 changed files with 8 additions and 2 deletions

View File

@ -81,9 +81,12 @@ class Controller:
logger.info("Starting controller %s with command: %s",
self.name, self.command)
try:
env = os.environ.copy()
env["PYTHONUNBUFFERED"] = "1"
self.process = await asyncio.create_subprocess_exec(
*shlex.split(self.command),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=env)
asyncio.ensure_future(
LogParser(self._get_log_source).stream_task(
self.process.stdout))

View File

@ -81,10 +81,13 @@ class Worker:
if self.closed.is_set():
raise WorkerError("Attempting to create process after close")
self.ipc = pipe_ipc.AsyncioParentComm()
env = os.environ.copy()
env["PYTHONUNBUFFERED"] = "1"
await self.ipc.create_subprocess(
sys.executable, "-m", "artiq.master.worker_impl",
self.ipc.get_address(), str(log_level),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=env)
asyncio.ensure_future(
LogParser(self._get_log_source).stream_task(
self.ipc.process.stdout))