areusch commented on a change in pull request #8236:
URL: https://github.com/apache/tvm/pull/8236#discussion_r649488030
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -703,6 +708,32 @@ def write(self, data, timeout_sec):
raise TransportClosedError()
return self.fd_transport.write(data, timeout_sec)
+ def _qemu_check_stdout(self):
+ for line in self.proc.stdout:
+ line = str(line)
+ _LOG.debug(line)
+ if "[QEMU] CPU" in line:
+ self._queue.put(True)
+ else:
+ line = re.sub("[^a-zA-Z0-9 \n]", "", line)
+ pattern = r"recipe for target (\w*) failed"
+ if re.search(pattern, line, re.IGNORECASE):
+ self._queue.put("make failed")
Review comment:
turn the strings into an enum e.g.
```
import enum
class ZephyrMakeResult(enum.Enum):
QEMU_STARTED = 'qemu_started'n
MAKE_FAILED = 'make_failed'
EOF = 'eof'
```
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -703,6 +708,32 @@ def write(self, data, timeout_sec):
raise TransportClosedError()
return self.fd_transport.write(data, timeout_sec)
+ def _qemu_check_stdout(self):
+ for line in self.proc.stdout:
+ line = str(line)
+ _LOG.debug(line)
+ if "[QEMU] CPU" in line:
+ self._queue.put(True)
+ else:
+ line = re.sub("[^a-zA-Z0-9 \n]", "", line)
+ pattern = r"recipe for target (\w*) failed"
+ if re.search(pattern, line, re.IGNORECASE):
+ self._queue.put("make failed")
+ self._queue.put("EOF")
+
+ def _wait_for_qemu(self):
+ threading.Thread(target=self._qemu_check_stdout, daemon=True).start()
+ while True:
+ try:
+ item = self._queue.get(timeout=120)
+ except:
+ _LOG.error("QEMU setup timeout.")
+
+ if item == True:
+ return
+ elif item == "make failed" or item == "EOF":
+ raise RuntimeError("QEMU setup failed.")
Review comment:
add an assert to the else case
##########
File path: python/tvm/micro/contrib/zephyr.py
##########
@@ -703,6 +708,32 @@ def write(self, data, timeout_sec):
raise TransportClosedError()
return self.fd_transport.write(data, timeout_sec)
+ def _qemu_check_stdout(self):
+ for line in self.proc.stdout:
+ line = str(line)
+ _LOG.debug(line)
+ if "[QEMU] CPU" in line:
+ self._queue.put(True)
+ else:
+ line = re.sub("[^a-zA-Z0-9 \n]", "", line)
+ pattern = r"recipe for target (\w*) failed"
+ if re.search(pattern, line, re.IGNORECASE):
+ self._queue.put("make failed")
+ self._queue.put("EOF")
+
+ def _wait_for_qemu(self):
+ threading.Thread(target=self._qemu_check_stdout, daemon=True).start()
+ while True:
+ try:
+ item = self._queue.get(timeout=120)
+ except:
+ _LOG.error("QEMU setup timeout.")
Review comment:
raise IoTimeoutError or something here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]