improve error handling in ShellScheduler

This commit is contained in:
2020-11-06 16:49:59 +01:00
parent 6eefa17f5a
commit 5d07e08618

View File

@@ -40,6 +40,7 @@ class _Task:
try:
await asyncio.sleep(self._delay)
except asyncio.CancelledError:
self._log.info(f"task {self._task_id} cancelled")
return
if self._callback is not None:
@@ -162,8 +163,11 @@ class ShellScheduler(TaskScheduler):
"{src_pathname}", shell_quote(src_pathname))
self._log.info(f"{task_id}: execute shell command: {cmd}")
try:
proc = await asyncio.shield(asyncio.create_subprocess_shell(cmd))
await asyncio.shield(proc.communicate())
except Exception as e:
self._log.error(f"{task_id}: {e}")
class FileManagerRule: