Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zeromq: unicode not allowed, use send_unicode

I am getting error on zeromq python while sending strings through ROUTER SOCKET. String type messages are receveid successfully but some times, a unicode message throws exception "Type Error: unicode not allowed. use send_unicode". Although I have been trying to use msg.encode('utf-8'). BUt I cant figure out a way to get over with it. I am on python 2.7.3. I am not using pyzmq (import zmq only). Looking forward to your suggesitons :) Thanks

if backend in sockets:

        request=backend.recv_multipart()
        #print ("Backend Thread is ready")
        worker_id,client_id = request[:2]

        if client_id != b"READY" and len(request) > 3:
            #print (len(request))
            empty2,reply  = request[2:]
            router_socket.send_multipart([client_id, reply.encode('utf-8')])
like image 568
Monster Avatar asked Mar 12 '15 12:03

Monster


1 Answers

The problem was resolved only thing was that I needed to convert the unicode strings back to ascii by using string.encode('ascii')

like image 176
Monster Avatar answered Oct 05 '22 07:10

Monster