File: //usr/local/CyberCP/lib/python3.10/site-packages/websockets/sync/__pycache__/utils.cpython-310.pyc
o
�hS � @ s, d dl mZ d dlZdgZG dd� d�ZdS )� )�annotationsN�Deadlinec @ s* e Zd ZdZddd�Zdd �ddd
�ZdS )r z�
Manage timeouts across multiple steps.
Args:
timeout: Time available in seconds or :obj:`None` if there is no limit.
�timeout�float | None�return�Nonec C s( | |d u rd | _ d S t�� | | _ d S )N)�deadline�time� monotonic)�selfr � r �H/usr/local/CyberCP/lib/python3.10/site-packages/websockets/sync/utils.py�__init__ s
zDeadline.__init__T)�raise_if_elapsedr �boolc C s4 | j du rdS | j t�� }|r|dkrtd��|S )aL
Calculate a timeout from a deadline.
Args:
raise_if_elapsed: Whether to raise :exc:`TimeoutError`
if the deadline lapsed.
Raises:
TimeoutError: If the deadline lapsed.
Returns:
Time left in seconds or :obj:`None` if there is no limit.
Nr z timed out)r r r
�TimeoutError)r r r r r r
r s
zDeadline.timeoutN)r r r r )r r r r )�__name__�
__module__�__qualname__�__doc__r r r r r r
r s
)�
__future__r r �__all__r r r r r
�<module> s