Google
Edit File: router.cpython-39.pyc
a ��j�% � @ s� d dl Z d dlZd dlZd dlmZmZmZ ddlmZm Z ddl mZmZm Z e�e�ZG dd� d�ZG dd � d �ZG d d� de�ZG dd � d �ZG dd� de �ZdS )� N)�Dict�List�Optional� )� JsonObject� JsonValue)�CockpitProblem�CockpitProtocolError�CockpitProtocolServerc @ s. e Zd ZdZdd� Zdd� Zdd�dd �ZdS ) �ExecutionQueueaw Temporarily delay calls to a given set of class methods. Functions by replacing the named function at the instance __dict__ level, effectively providing an override for exactly one instance of `method`'s object. Queues the invocations. Run them later with .run(), which also reverses the redirection by deleting the named methods from the instance. c C s* t �� | _|| _| jD ]}| �|� qd S �N)�collections�deque�queue�methods�_wrap)�selfr �method� r �2/usr/lib/python3.9/site-packages/cockpit/router.py�__init__ s zExecutionQueue.__init__c s t � j� jj� �fdd�� d S )Nc s �j �� | f�S r )r �append)�args�r r r r �<lambda>% � z&ExecutionQueue._wrap.<locals>.<lambda>)�setattr�__self__�__func__�__name__)r r r r r r ! s zExecutionQueue._wrapN��returnc C sJ t �dt| j�� | jD ]\}}||� q| jD ]}t|j|jj� q0d S )Nz.ExecutionQueue: Running %d queued method calls) �logger�debug�lenr r �delattrr r r )r r r r r r �run'