Commit 4b1a499fcb8 by Pierre Augier

Raise error if error during Pythran/Cython compilation.

parent 3153c9c01ff
......@@ -147,7 +147,7 @@ class CheckCompiling:
return self.func(*args, **kwargs)
ts = self.ts
if ts.is_compiling and not ts.process.is_alive():
if ts.is_compiling and not ts.process.is_alive(raise_if_error=True):
ts.is_compiling = False
time.sleep(0.1)
ts.module_backend = import_from_path(
......@@ -489,7 +489,7 @@ class Transonic:
"`use_block` has to be used protected by `if ts.is_transpiled`"
)
if self.is_compiling and not self.process.is_alive():
if self.is_compiling and not self.process.is_alive(raise_if_error=True):
self.is_compiling = False
time.sleep(0.1)
self.module_backend = import_from_path(
......
......@@ -379,7 +379,6 @@ class Backend:
parallel=True,
force=True,
):
print("compile extension")
for path in paths:
self.compile_extension(
path,
......
......@@ -171,7 +171,14 @@ class SchedulerPopen:
process = None
if mpi.rank == 0:
process = subprocess.Popen(words_command, cwd=cwd)
stdout = stderr = subprocess.PIPE
process = subprocess.Popen(
words_command,
cwd=cwd,
stdout=stdout,
stderr=stderr,
universal_newlines=True,
)
process = mpi.ShellProcessMPI(process)
......
......@@ -354,7 +354,7 @@ class JIT:
def type_collector(*args, **kwargs):
if self.compiling:
if not self.process.is_alive():
if not self.process.is_alive(raise_if_error=True):
self.compiling = False
time.sleep(0.1)
backend_module = import_from_path(
......
......@@ -116,15 +116,31 @@ class ShellProcessMPI:
self.process = process
self.root = root
def is_alive(self):
def is_alive(self, raise_if_error=False):
if rank == self.root:
is_alive = self.is_alive_root()
is_alive = self.is_alive_root(raise_if_error=raise_if_error)
else:
is_alive = None
return bcast(is_alive, self.root)
def is_alive_root(self):
return self.process.poll() is None
def is_alive_root(self, raise_if_error=False):
process = self.process
is_alive_ = process.poll() is None
if not is_alive_ and process.returncode:
if process.stdout:
print(process.stdout.read(), flush=True)
if process.stderr:
from transonic.log import logger
logger.error(process.stderr.read())
if raise_if_error:
raise RuntimeError(
"Error while compiling code generated by Transonic."
)
return is_alive_
PathSeq = Path
......
......@@ -17,7 +17,7 @@ from time import time, sleep
from shutil import copyfile
import os
logger = logging.getLogger("pythran_fluid")
logger = logging.getLogger("transonic")
logger.setLevel(logging.INFO)
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
......@@ -147,6 +147,7 @@ def main():
logger.error(
f"{backend.capitalize()} stderr:\n{completed_process.stderr}"
)
sys.exit(1)
if __name__ == "__main__":
......
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