3
ò\ð]  ã               @   sœ   d dl mZ d dlZd dlmZ d dlmZ yd dlZdZW n ek
rT   dZY nX G dd„ dej	ƒZ
G d	d
„ d
eƒZe
ejejeerŒendejdœZdS )é    )Úabsolute_importN)Úqueue)ÚEventTFc                   s.   e Zd ZdZg i f‡ fdd„	Zdd„ Z‡  ZS )ÚThreadz€
    This wrapper class provides gevent Greenlet interface that is compatible
    with the standard library's Thread class.
    c                s   t t| ƒj|f|ž|Ž d S )N)Úsuperr   Ú__init__)ÚselfÚtargetÚargsÚkwargs)Ú	__class__© úH/tmp/pip-build-mqc4i71p/python-engineio/engineio/async_drivers/gevent.pyr      s    zThread.__init__c             C   s   | j ƒ S )N)Úrun)r   r   r   r   Ú_run   s    zThread._run)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   )r   r   r      s   r   c               @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚWebSocketWSGIzy
    This wrapper class provides a gevent WebSocket interface that is
    compatible with eventlet's implementation.
    c             C   s
   || _ d S )N)Úapp)r   r   r   r   r   r      s    zWebSocketWSGI.__init__c             C   sR   d|krt dƒ‚|d | _|| _| jj| _| jj| _| jj| _| jj| _| j| ƒS )Nzwsgi.websocketzrYou need to use the gevent-websocket server. See the Deployment section of the documentation for more information.)ÚRuntimeErrorÚ_sockÚenvironÚversionÚpathÚoriginÚprotocolr   )r   r   Zstart_responser   r   r   Ú__call__!   s    




zWebSocketWSGI.__call__c             C   s
   | j jƒ S )N)r   Úclose)r   r   r   r   r    .   s    zWebSocketWSGI.closec             C   s   | j j|ƒS )N)r   Úsend)r   Úmessager   r   r   r!   1   s    zWebSocketWSGI.sendc             C   s
   | j jƒ S )N)r   Zreceive)r   r   r   r   Úwait4   s    zWebSocketWSGI.waitN)	r   r   r   r   r   r   r    r!   r#   r   r   r   r   r      s   r   )Úthreadr   Zqueue_emptyÚeventZ	websocketÚsleep)Ú
__future__r   Zgeventr   Zgevent.eventr   ZgeventwebsocketZ_websocket_availableÚImportErrorZGreenletr   Úobjectr   ZJoinableQueueÚEmptyr&   Z_asyncr   r   r   r   Ú<module>   s    
 
