ó .Åt_c@sBdZddlZdefd„ƒYZdefd„ƒYZdS(sƒ Timeout - context manager that implements a timeout. $Id: //eng/vdo-releases/magnesium/src/python/vdo/utils/Timeout.py#1 $ iÿÿÿÿNt TimeoutErrorcBs#eZdZdd„Zd„ZRS(s(Exception raised when a block times out.cOs;tt|ƒj||Ž|dkr.d}n||_dS(Nttimeout(tsuperRt__init__tNonet_msg(tselftmsgtargstkwargs((s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyR s  cCs|jS(N(R(R((s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyt__str__%sN(t__name__t __module__t__doc__RRR (((s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyRs tTimeoutcBs5eZdZd„Zd„Zdd„Zd„ZRS(sÞContext manager for running a block of commands under a timeout. If the block times out, a TimeoutError is raised. Arguments: seconds (int) - timeout in seconds msg (str) - message to supply to TimeoutError cs5tjtj‡fd†ƒˆ_tjˆjƒˆS(Ncs ˆjƒS(N(t_timeout(t_signumt_frame(R(s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyt;s(tsignaltSIGALRMt_Timeout__oldHandlertalarmt_Timeout__seconds(R((Rs5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyt __enter__8s cCs'tjdƒtjtj|jƒtS(Ni(RRRRtFalse(Rt exceptionTypetexceptionValuet traceback((s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyt__exit__As cCs||_||_d|_dS(N(Rt _Timeout__msgRR(RtsecondsR((s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyRJs  cCst|jƒ‚dS(s+ Method invoked if the alarm goes off. N(RR(R((s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyRRsN(R R R RRRRR(((s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyR)s  (R Rt ExceptionRtobjectR(((s5/usr/lib/python2.7/site-packages/vdo/utils/Timeout.pyts