[Twisted-Python] New user questions

snacktime snacktime at gmail.com
Sun Feb 6 13:12:49 MST 2005


> > I looked at the docs for writing servers and applications, that part
> > was pretty easy.  What I don't understand yet is how to write a server
> > that calls a function that blocks.
> 
> Either:
> 1. Restructure it to not block. For network code this tends to be a side
> effect of  using Twisted. E.g. twisted.protocols.smtp.sendmail does a
> single logical operation, "send an email", but it does not block
> because actions internally are split up based on networking events
> driven by the event loop - socket readable, socket writable.
> 
> 2. Actions that can't be broken up, typically a C extension call that
> may take a long time, can be run in a thread pool. See e.g. how
> twisted.enterprise.adbapi works.
> 
> bsddb may or may not count as blocking depending how you use it.

The problem I am having is getting my head around async io and using
callbacks.  I've just never had to deal with it before on this level.

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.




More information about the Twisted-Python mailing list