B
     9-eY  ã               @   sB   d Z ddlZddlmZ ddlmZ e e¡ZG dd„ deƒZ	dS )zÊ
Copyright (C) 2019 Interactive Brokers LLC. All rights reserved. This code is subject to the terms
 and conditions of the IB API Non-Commercial License or the IB API Commercial License, as applicable.
é    N)ÚThread)Úcommc                   s$   e Zd Z‡ fdd„Zdd„ Z‡  ZS )ÚEReaderc                s   t ƒ  ¡  || _|| _d S )N)ÚsuperÚ__init__ÚconnÚ	msg_queue)Úselfr   r   )Ú	__class__© ú®G:\My Drive\STUDY\EPAT\09 TBP - Trading & Back-testing Platforms\TBP04 - Backtesting & Live Trading\IB IBridgePy API\02 Python 3.7 IBridgePy_Win_Anaconda37_64\ibapi\reader.pyr      s    
zEReader.__init__c             C   sÀ   y¤t  d¡ d}x†| j ¡ r–| j ¡ }t  dt|ƒ¡ ||7 }xTt|ƒdkr’t |¡\}}}t  d|t|ƒ|d¡ |r„| j 	|¡ q@t  d¡ P q@W qW t  d¡ W n   t  
d	¡ Y nX d S )
NzEReader thread startedó    zreader loop, recvd size %dr   z$size:%d msg.size:%d msg:|%s| buf:%s|ú|z#more incoming packet(s) are needed zEReader thread finishedz%unhandled exception in EReader thread)ÚloggerÚdebugr   ÚisConnectedÚrecvMsgÚlenr   Úread_msgr   ÚputÚ	exception)r	   ÚbufÚdataÚsizeÚmsgr   r   r   Úrun   s$    



zEReader.run)Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__r   r   )r
   r   r      s   r   )
Ú__doc__ÚloggingÚ	threadingr   Úibapir   Ú	getLoggerr   r   r   r   r   r   r   Ú<module>   s
   

