Commit 37491e4f authored by Xavier Thompson's avatar Xavier Thompson

slapgrid: Fix promise deadlock

Avoid use Popen.communicate instead of SlapPopen to run promises,
because SlapPopen uses threads and preexec_fn is not thread-safe.

The drawback is that logs are not propagated in real-time anymore,
but only once the promise process completes.
parent 48d46cca
......@@ -739,17 +739,17 @@ stderr_logfile_backups=1
dropPrivileges(uid, gid, logger=self.logger)
os.dup2(err, 2)
try:
process = SlapPopen(
process = subprocess.Popen(
command,
preexec_fn=preexec_fn,
cwd=instance_path,
universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
logger=self.logger,
timeout=timeout,
)
stderr = process.stderr.read()
stdout, stderr = process.communicate(timeout=timeout)
for line in stdout.splitlines():
self.logger.info(line)
if process.returncode == 2:
raise PromiseError(stderr)
elif process.returncode:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment