I try to implement a REQ/REP pattern, with python3 asyncio and ZeroMQ
My client async function:
import zmq
import os
from time import time
import asyncio
import zmq.asyncio
print ('Client %i'%os.getpid())
context = zmq.asyncio.Context(1)
loop = zmq.asyncio.ZMQEventLoop()
asyncio.set_event_loop(loop)
async def client():
socket = context.socket(zmq.REQ)
socket.connect('tcp://11.111.11.245:5555')
while True:
data = zmq.Message(str(os.getpid()).encode('utf8'))
start = time()
print('send')
await socket.send(data)
print('wait...')
data = await socket.recv()
print('recv')
print(time() - start, data)
loop.run_until_complete(client())
As I understand, the call to a socket.connect( "tcp://11.111.11.245:5555" ) method is a blocking method.
How to make a non-blocking connection call, in my case?