forked from M-Labs/artiq
1
0
Fork 0

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", logger.info("Starting controller %s with command: %s",
self.name, self.command) self.name, self.command)
try: try:
env = os.environ.copy()
env["PYTHONUNBUFFERED"] = "1"
self.process = await asyncio.create_subprocess_exec( self.process = await asyncio.create_subprocess_exec(
*shlex.split(self.command), *shlex.split(self.command),
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=env)
asyncio.ensure_future( asyncio.ensure_future(
LogParser(self._get_log_source).stream_task( LogParser(self._get_log_source).stream_task(
self.process.stdout)) self.process.stdout))

View File

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