[Twisted-Python] Re: writing back to the connection is blocking my code
coder_gus at lavabit.com
Fri Mar 21 10:07:36 EDT 2008
Hi, thanks for answering and clarifying this - until now you where the
only one that told me there no way of sending data if there is no event
on the server. So what I am trying to achieve, I have asked a couple of
weeks ago too about this matter (actually about the architecure): I want
to write an application server that receives data from clients (client
app written in delphi), data is in xml format (I want to write it using
a bare-bone protocol and not an xml-rpc server). The data the client
sends are some requests for some specific data hold in a database. So,
the client makes a request, request that is hold in a synchronized queue
together with an instance of the client's connection. A coordinator
takes the data from that queue and gives it to some xml threads to parse
it and the same coordinator take the parsed data from the xml threads
and give some workers to do the bussiness work. This workers place the
result in a queue from where the coordinator takes care of sending it
back to the clients. I will be using sqlalchemy for database communication.
I know the architecture is pretty weird from the twisted perspective,
but when the dev-manager wants to do it that way, what can you do? So
that is the thing I want to achieve and from this started my question;
when the workers finish their work, they have the result, place it in a
queue and from there I have to send it to the clients asap, without
waiting the server for events.
Not sure if I made myself clear as I am not a native-English speaker.
Thanks for you patience. :)
Thomas Hervé wrote:
> Quoting coder_gus <coder_gus at lavabit.com>:
>> Agreed, I was talking about transport.tcpKeepAlive(). The thing I am
>> asking (and call me stupid, but I am trying to figure it out for days
>> now and no one seems to answer my question or is it me too stupid that
>> can see the answer in front of my eyes) is how do I send data to
>> clients that are connected to the twisted server waiting for data to be
>> processed, without sending to the server any data or causing any event
>> to the server?
> This is where you are confused I think. There is no way to send data
> to clients if you don't have *any* events on the server. Because how
> would you now to send data if you don't have something telling you to
> do so? You should have a time event, or a network event from another
> client, or a GUI input, or whatever.
>> In the link you guys showed me it's true that the data
>> gets back to the clients, but only when the server receives other data,
>> that is in the dataReceived method. How can I send it back to them
>> (having a reference to each client's protocol class) without receiving
>> data, client connecting etc. ?
> It's not totally clear to understand what you're trying to achieve, so
> maybe you want to explain more clearly your problem. I suspect you
> want to use reactor.callLater, to generate a time event.
More information about the Twisted-Python