From 41a90f125ab5475d3c3afd78b1cedfa1e8b85062 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 3 Sep 2010 17:47:22 -0700 Subject: [PATCH] Use AlarmSignal for alarm timeout in action_sync(). --- pym/_emerge/actions.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index d84e434d6..0da1d685b 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -2127,14 +2127,12 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): content = None mypids = [] try: - def timeout_handler(signum, frame): - raise portage.exception.PortageException("timed out") - signal.signal(signal.SIGALRM, timeout_handler) # Timeout here in case the server is unresponsive. The # --timeout rsync option doesn't apply to the initial # connection attempt. if rsync_initial_timeout: - signal.alarm(rsync_initial_timeout) + portage.exception.AlarmSignal.register( + rsync_initial_timeout) try: mypids.extend(portage.process.spawn( mycommand, returnpid=True, **spawn_kwargs)) @@ -2145,15 +2143,14 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): content = portage.grabfile(tmpservertimestampfile) finally: if rsync_initial_timeout: - signal.alarm(0) + portage.exception.AlarmSignal.unregister() try: os.unlink(tmpservertimestampfile) except OSError: pass - except portage.exception.PortageException as e: + except portage.exception.AlarmSignal: # timed out - print(e) - del e + print('timed out') if mypids and os.waitpid(mypids[0], os.WNOHANG) == (0,0): os.kill(mypids[0], signal.SIGTERM) os.waitpid(mypids[0], 0) -- 2.26.2