%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.6/site-packages/pyzor/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.6/site-packages/pyzor/__pycache__/forwarder.cpython-36.pyc

3

�2�^
�@sRdZddlZddlZyddlZWnek
r<ddlZYnXGdd�de�ZdS)zManage the forwarder process.�Nc@s<eZdZdZddd�Zdd�Zddd	�Zd
d�Zdd
�ZdS)�	Forwarderz'Forwards digest to remote pyzor servers�'cCs(tjd�|_||_tj|�|_||_dS)a
        forward_client: a pyzor.client.Client instance to use as
                        forwarding client
        remote_servers: a list of (hostname,port) tuples where digests should
                        be forwarded to
        max_queue_size: max amount of queued digests
        ZpyzordN)�loggingZ	getLogger�log�forwarding_client�Queue�
forward_queue�remote_servers)�selfrr	Zmax_queue_size�r�/usr/lib/python3.6/forwarder.py�__init__s	zForwarder.__init__cCs�x�y|jjddd�\}}Wn&tjk
r@|jdkr:dSwYnXxj|jD]`}y&|rd|jj||�n|jj||�WqJtk
r�}z|j	j
d|||�WYdd}~XqJXqJWqWdS)z'read forwarding requests from the queueT�)�blockZtimeoutNz%Forwarding digest %s to %s failed: %s)r�getrZEmptyrr	�	whitelistZreport�	Exceptionr�warn)r
�digestrZserverZexrrr�
_forward_loops 
zForwarder._forward_loopFcCs>|jdkrdSy|jj||f�Wntjk
r8YnXdS)z�If forwarding is enabled, insert a digest into the forwarding queue
        if whitelist is True, the digest will be forwarded as whitelist request
        if the queue is full, the digest is dropped
        N)rrZ
put_nowaitrZFull)r
rrrrr�queue_forward_request5s
zForwarder.queue_forward_requestcCstj|jd�j�dS)zstart the forwarding thread)�targetN)�	threadingZThreadr�start)r
rrr�start_forwardingBszForwarder.start_forwardingcCs
d|_dS)z?disable forwarding and tell the forwarding thread to end itselfN)r)r
rrr�stop_forwardingFszForwarder.stop_forwardingN)r)F)	�__name__�
__module__�__qualname__�__doc__r
rrrrrrrrrs



r)rrrr�ImportErrorZqueue�objectrrrrr�<module>s

Zerion Mini Shell 1.0