According to your questions:
What is the purpose of mdp_request method when there is a request method available?
as it's written in code:
mdp_request is synchronous MDP request
MDPClient class is asynchronous encapsulation of a zmq.REQ socket and is meant to be integrated into the asynchronous IOLoop of pyzmq.
What is wrong with my approach?
I was struggling with the same problem. After checking the test_client.py I was able to solve it with such example:
import zmq
from zmq.eventloop.ioloop import IOLoop
from mdp.client import MDPClient
class MyClient(MDPClient):
def on_message(self, msg):
print("Received:", repr(msg))
IOLoop.instance().stop()
return
def on_timeout(self):
print('TIMEOUT!')
IOLoop.instance().stop()
return
if __name__ == '__main__':
context = zmq.Context()
client = MyClient(context, 'tcp://127.0.0.1:5555', b'echo')
client.request(b'Hello world', timeout=3000)
IOLoop.instance().start()
client.shutdown()