Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskManager fork_task should ensure exceptions are logged before exiting #32

Closed
rohanpm opened this issue Mar 28, 2017 · 0 comments
Closed

Comments

@rohanpm
Copy link
Member

rohanpm commented Mar 28, 2017

In TaskManager class, here's the body of fork_task currently:

def fork_task(self, task_info):
    self.log_debug("Forking task %s" % self._task_str(task_info))

    pid = os.fork()
    if pid:
        self.log_info("Task forked %s: pid=%s" % (self._task_str(task_info), pid))
        return pid

    # in no circumstance should we return after the fork
    # nor should any exceptions propagate past here
    try:
        # set process group
        os.setpgrp()

        # set a do-nothing handler for sigusr2
        # do not use signal.signal(signal.SIGUSR2, signal.SIG_IGN) - it completely masks interrups !!!
        signal.signal(signal.SIGUSR2, lambda *args: None)

        # set a default handler for SIGTERM
        signal.signal(signal.SIGTERM, signal.SIG_DFL)

        # run the task
        self.run_task(task_info)
    finally:
        # die
        os._exit(os.EX_OK)

If run_task raises any exception, it's never logged, and the process exits with 0 exit code giving no indication of an error.

It seems that any exceptions here should be logged, so that problems from run_task (e.g. failed XML-RPC calls to hub) leave some evidence behind.

rohanpm added a commit to rohanpm/kobo that referenced this issue Jan 4, 2019
When a task was run from fork_task, any uncaught exceptions would
be silently discarded (e.g. a communication failure between worker
and hub). This makes debugging more difficult than it should be.

Make sure any raised exception is logged in this block.

Fixes release-engineering#32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant