> Well, we have uWSGI instances that are using the uWSGI rpc subsystem to
> make calls to our uWSGI rpc services, which is all working fine, but we
> also want to have a few non uWSGI apps to be able to make rpc calls to the
> uWSGI rpc services as well.
>
> With the help of Stack
> Overflow<http://stackoverflow.com/questions/15981891>,
> we were able to come up with a very rough test, but it's raw and scary
> even
> if we package it and test it heavily.
>
>
> import socket
> from struct import pack, unpack
>
> c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> c.connect(('127.0.0.1', 3737))
>
> #test call
> fun = 'testing_call'
> arg = 'the test param'
>
> #header
> ulen = len(fun)
> arglen = len(arg)
> buflen = (2 + ulen) + (2 + arglen)
> buf = pack('<B', 173)
> buf += pack('<H', buflen)
> buf += pack('<B', 0)
> c.send(buf)
>
> #body
> buf = pack('<B', ulen & 0xff)
> buf += pack('<B', (ulen>>8) & 0xff)
> buf += fun
> buf += pack('<B', arglen & 0xff)
> buf += pack('<B', (arglen>>8) & 0xff)
> buf += arg
> sent = c.send(buf)
>
> #print response
> print "sent", sent
> resp = c.recv(4)
> fsize = unpack('<H', resp[1:3])[0]
> resp = c.recv(fsize)
> print "resp", resp
>
> c.close()


I think you will be able to write the code with half the lines, you may
want to look at the perl Net::uwsgi module, you can base a python module
on it:

https://github.com/unbit/perl-net-uwsgi/blob/master/lib/Net/uwsgi.pm

check the uwsgi_pkt functions, it encode hashes, arrays and strings in the
uwsgi format

-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to