ok
Direktori : /opt/alt/python311/lib64/python3.11/__pycache__/ |
Current File : //opt/alt/python311/lib64/python3.11/__pycache__/sched.cpython-311.pyc |
� �f� � �" � d Z ddlZddlZddlmZ ddlmZ ddlZddlmZ dgZ edd� � Zd ej _ d ej _ dej _ dej _ d ej _ dej _ e� � Z G d� d� � ZdS )a� A generally useful event scheduler class. Each instance of this class manages its own queue. No multi-threading is implied; you are supposed to hack that yourself, or use a single instance per application. Each instance is parametrized with two functions, one that is supposed to return the current time, one that is supposed to implement a delay. You can implement real-time scheduling by substituting time and sleep from built-in module time, or you can implement simulated time by writing your own functions. This can also be used to integrate scheduling with STDWIN events; the delay function is allowed to modify the queue. Time can be expressed as integers or floating point numbers, as long as it is consistent. Events are specified by tuples (time, priority, action, argument, kwargs). As in UNIX, lower priority numbers mean higher priority; in this way the queue can be maintained as a priority queue. Execution of the event means calling the action function, passing it the argument sequence in "argument" (remember that in Python, multiple function arguments are be packed in a sequence) and keyword parameters in "kwargs". The action function may be an instance method so it has another way to reference private data (besides global variables). � N)� namedtuple)�count)� monotonic� scheduler�Eventz2time, priority, sequence, action, argument, kwargszaNumeric type compatible with the return value of the timefunc function passed to the constructor.zSEvents scheduled for the same time will be executed in the order of their priority.zbA continually increasing sequence number that separates events if time and priority are equal.z?Executing the event means executing action(*argument, **kwargs)zGargument is a sequence holding the positional arguments for the action.zDkwargs is a dictionary holding the keyword arguments for the action.c �f � e Zd Zeej fd�Zdefd�Zdefd�Z d� Z d� Zdd�Ze d � � � Zd S )r c � � g | _ t j � � | _ || _ || _ t � � | _ dS )zGInitialize a new instance, passing the time and delay functionsN)�_queue� threading�RLock�_lock�timefunc� delayfuncr �_sequence_generator)�selfr r s �,/opt/alt/python311/lib64/python3.11/sched.py�__init__zscheduler.__init__5 s: � � ����_�&�&�� � �� �"���#(�7�7�� � � � � c �� � |t u ri }| j 5 t ||t | j � � |||� � }t j | j |� � ddd� � n# 1 swxY w Y |S )z�Enter a new event in the queue at an absolute time. Returns an ID for the event which can be used to remove it, if necessary. N)� _sentinelr r �nextr �heapq�heappushr )r �time�priority�action�argument�kwargs�events r �enterabszscheduler.enterabs>