3
­Ý ^­  ã               @   sv   d Z ddlZddlZddlZddlmZmZ ddlmZ ddl	m
Z
 ddlmZ dZdd	„ Zd
d„ Zdekrreƒ  dS )z'
Test flow broker with example handler
é    N)Ú	objectifyÚBroker)ÚFactory)Úspawner)ÚZActorztcp://127.0.0.1:5679c             G   sæ   |j ƒ  tjdtjdƒ}|jtƒ |jd ƒ tjj	|ƒ}tj
tjtddd�ƒd�}|j|ƒ td|f ƒ |jdƒ}|s|t‚td	|f ƒ xtd
ƒD ]}|jtj
ƒ ƒ q”W tdƒ |jƒ  tdƒ |jƒ }|sÒt‚tdƒ |jƒ  d S )NÚclientÚ Úextracté   )Ú	directionZcredit)Zlabelzclient sent BOT:
%s
iè  zclient got BOT:
%s
é
   zclient sent DATzclient sent EOTzclient done)ÚsignalÚzioÚPortÚzmqZCLIENTZconnectÚserver_addressÚonlineZflowZFlowZMessageÚjsonÚdumpsÚdictZsend_botÚprintZrecv_botÚAssertionErrorÚrangeZputZsend_eotZrecv_eotZrecv)ÚctxÚpipeÚargsZportZcflowÚmsgÚcount© r   ú./home/yuhw/zmq/zio/python/tests/test_broker.pyÚclient_actor   s(    



r    c              C   sª   t jƒ } tjdt jƒ}|jtƒ |jƒ  |jƒ  t	| t
ƒ}ttƒ}t	| t|ƒ}t||jƒ}x0tdƒD ]$}td|› d�ƒ |jdƒ}|sdP qdW tdƒ |jƒ  |jjƒ  d S )NZserveré   zmain: poll [ú]iè  zmain: stopping)r   ZContextr   r   ZSERVERZbindr   Zdo_bindsr   r   r    r   r   r   r   r   r   ZpollÚstopr   )r   Zsportr   ÚfactoryZbackendZbrokerr   Úokr   r   r   Útest_broker*   s"    


r&   Ú__main__)Ú__doc__r   r   r   Zzio.flowr   r   Zzio.flow.example_handlerr   Zzio.flow.backendr   Zpyre.zactorr   r   r    r&   Ú__name__r   r   r   r   Ú<module>   s   