Il giorno 30/mag/2012, alle ore 20:21, Tobia Conforto ha scritto:

> On 30 May 2012, at 20:03, Roberto De Ioris wrote:
>> If i understand correctly the JAVA service opens the connection to uWSGI, 
>> make a HTTP/uwsgi request, then uWSGI itself has to make a request to the 
>> java service over the same connection, wait for the response and finally 
>> send the WSGI/HTTP output.
> 
> Hi Roberto,
> we met at Django Day! I was the guy asking questions about FLUP.
> 
> Yes, that's basically the flow.
> 
> The reason is that the Python app occasionally needs to issue Java remote 
> calls, and that those calls may need to access the local Java state. So my 
> idea is to ask uWSGI to send back a different packet, instead of the HTTP 
> output, and wait for the reply to that. On the Java side, I can just wait on 
> the connection, and select between a HTTP output packet or a RPC one.
> 
> Is this doable on the Python side? How would I ask uWSGI: "please send this 
> packet (the RPC request) over the same connection and now wait for this other 
> kind of packet (the RPC reply) and return its contents to me (the Python 
> code)"?
> 
> Tobia
> 

[DISCLAIMER]
the following code is totally non-standard and WEB-SIG gurus will probably try 
to kill me for having showed you that:

You can send data in real-time to the underlying socket with

uwsgi.send(data)

Example:

http://projects.unbit.it/uwsgi/browser/welcome.py#L46

Receiving data is a bit hacky.

First you have to get the file descriptor of the socket with:

s = env['wsgi.input'].fileno()

then you can receive data with:

data = uwsgi.recv(s)

(the maximum size of data is 4k chunk)

In that way you should be able to make whatever you want.


--
Roberto De Ioris
http://unbit.it
JID: [email protected]

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

Reply via email to