[Twisted-Python] New user questions

Eric Mangold teratorn at twistedmatrix.com
Mon Feb 7 11:08:03 EST 2005

On Sun, 6 Feb 2005 13:30:55 -0800, snacktime <snacktime at gmail.com> wrote:

> On Sun, 06 Feb 2005 16:17:17 -0500, Itamar Shtull-Trauring
> <itamar at itamarst.org> wrote:
>> On Sun, 2005-02-06 at 12:12 -0800, snacktime wrote:
>> > Maybe someone could show me the basic logic of how I would structure
>> > the following to be non blocking?
>> >
>> > 1.  Client sends message to server
>> > 2.  Server does an https POST to another server and gets a response
>> > 3.  Server sends a message back to the client and closes the  
>> connection.
>> Server receives data from client -> server sends POST to another server.
>> Server receives response from another server -> server sends message
>> back to client and closes connection.
>> Server sending POST would probably use twisted.web.client and be a
>> single function call, but internally be:
>> Open connection to another server.
>> Connection made -> send HTTP request.
>> HTTP response receoved -> do something.
>> Receiving data is:
>> Received data -> check if we've received enough to process protocol
>> message, if so process message, otherwise buffer data.
> Ok, so basically I have to write my application so it does not block,
> which means anything that does block has to be rewritten using
> appropriate twisted components that don't block.  For instance, there
> isn't a way to use urllib2 to do the POST and make it not block,
> correct?


> So I guess the main problem that arises is when calling some code that
> blocks, but there is no twisted component that you can use to make the
> code non blocking.  In which case you have to resort to using threads
> or processes correct?

Correct. http://twistedmatrix.com/documents/current/howto/threading

(or it should be possible to use Stackless Python with radix's
Deferred support code, in the sandbox; it's experimental of course)


> Chris
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list