File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/zmq/__pycache__/decorators.cpython-310.pyc
Back
o ;j� � @ sj d Z ddlmZ dZddlmZ ddlZG dd� d�ZG dd � d e�ZG d d� de�Z dd � Z dd� ZdS )ae Decorators for running functions with context/sockets. .. versionadded:: 15.3 Like using Contexts and Sockets as context managers, but with decorator syntax. Context and sockets are closed at the end of the function. For example:: from zmq.decorators import context, socket @context() @socket(zmq.PUSH) def work(ctx, push): ... � )�annotations)�context�socket��wrapsNc @ s2 e Zd ZdZddd�Zdd� Zdd� Zd d � ZdS )� _DecoratorzThe mini decorator factoryNc C s || _ d S �N��_target)�self�target� r �B/opt/saltstack/salt/lib/python3.10/site-packages/zmq/decorators.py�__init__$ s z_Decorator.__init__c s, �j � i ���\�� �� ���fdd�}|S )a� The main logic of decorator Here is how those arguments works:: @out_decorator(*dec_args, *dec_kwargs) def func(*wrap_args, **wrap_kwargs): ... And in the ``wrapper``, we simply create ``self.target`` instance via ``with``:: target = self.get_target(*args, **kwargs) with target(*dec_args, **dec_kwargs) as obj: ... c s t � ���� ��fdd��}|S )Nc s� �j | i |��}|� i ����0}�r�|vr||�<