� .�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