From 8f8a81c3f6aea0216cb609c573a62ad21662d665 Mon Sep 17 00:00:00 2001 From: "Silas S. Brown" <ssb22@cam.ac.uk> Date: Thu, 26 Oct 2017 09:04:33 +0000 Subject: [PATCH] Update Web Adjuster git-svn-id: http://svn.code.sf.net/p/e-guidedog/code/ssb22/adjuster@2946 29193198-4895-4776-b068-10539e920549 --- adjuster.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/adjuster.py b/adjuster.py index 6375d1b..1da0445 100755 --- a/adjuster.py +++ b/adjuster.py @@ -1564,19 +1564,21 @@ def webdriverWrapper_receiver(pipe): pipe.send(("INT","INT")) return pipe.close() if cmd=="EOF": return pipe.close() - try: signal.alarm(100) # as a backup: if Selenium timeout somehow fails, don't let this process get stuck forever (can do this only when PhantomJS_multiprocess or we won't know what thread gets it) - except: pass # alarm() is Unix-only - try: ret,exc = getattr(w,cmd)(*args), None - except Exception, e: - p = find_adjuster_in_traceback() - if p: # see if we can add it to the message: + try: + try: signal.alarm(100) # as a backup: if Selenium timeout somehow fails, don't let this process get stuck forever (can do this only when PhantomJS_multiprocess or we won't know what thread gets it) + except: pass # alarm() is Unix-only + try: ret,exc = getattr(w,cmd)(*args), None + except Exception, e: + p = find_adjuster_in_traceback() + if p: # see if we can add it to the message: try: if type(e.args[0])==str: e.args=(repr(e.args[0])+p,) + tuple(e.args[1:]) # should work with things like httplib.BadStatusLine that are fussy about the number of arguments they get else: e.args += (p,) # works with things like KeyError (although so should the above) except: e.message += p # works with base Exception - ret,exc = None,e - try: signal.alarm(0) - except: pass # Unix-only + ret,exc = None,e + try: signal.alarm(0) + except: pass # Unix-only + except Exception, e: ret,exc = None,e # e.g. if 1st 'except' block catches a non-sigalarm exception but then the alarm goes off while it's being handled try: pipe.send((ret,exc)) except: pass # if they closed it, we'll get EOFError on next iteration def webdriverWrapper_send(pipe,cmd,args=()): -- GitLab