Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/vdo/utils/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/vdo/utils/__pycache__/Timeout.cpython-36.pyc

3

x?ag��@s`dZddlmZddlmZddlmZddlmZddlZGdd�de�ZGd	d
�d
e	�Z
dS)z�

  Timeout - context manager that implements a timeout.

  $Id: //eng/vdo-releases/aluminum/src/python/vdo/utils/Timeout.py#1 $

�)�absolute_import)�division)�print_function)�unicode_literalsNcs*eZdZdZd�fdd�	Zdd�Z�ZS)�TimeoutErrorz(Exception raised when a block times out.Ncs(tt|�j||�|dkrd}||_dS)NZtimeout)�superr�__init__�_msg)�self�msg�args�kwargs)�	__class__��/usr/lib/python3.6/Timeout.pyr$szTimeoutError.__init__cCs|jS)N)r	)r
rrr�__str__)szTimeoutError.__str__)N)�__name__�
__module__�__qualname__�__doc__rr�
__classcell__rr)rrr"src@s2eZdZdZdd�Zdd�Zddd�Zd	d
�ZdS)�Timeoutz�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
  cs(tjtj�fdd���_tj�j��S)Ncs�j�S)N)�_timeout)Z_signumZ_frame)r
rr�<lambda>?sz#Timeout.__enter__.<locals>.<lambda>)�signal�SIGALRM�_Timeout__oldHandler�alarm�_Timeout__seconds)r
r)r
r�	__enter__<szTimeout.__enter__cCstjd�tjtj|j�dS)NrF)rrrr)r
Z
exceptionTypeZexceptionValue�	tracebackrrr�__exit__Es
zTimeout.__exit__NcCs||_||_d|_dS)N)r�
_Timeout__msgr)r
ZsecondsrrrrrNszTimeout.__init__cCst|j��dS)z+ Method invoked if the alarm goes off.
    N)rr")r
rrrrVszTimeout._timeout)N)rrrrrr!rrrrrrr-s
		
r)rZ
__future__rrrrr�	Exceptionr�objectrrrrr�<module>s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists