[Twisted-Python] New user questions

Itamar Shtull-Trauring itamar at itamarst.org
Sun Feb 6 11:27:09 EST 2005

On Sat, 2005-02-05 at 21:05 -0800, snacktime wrote:

> 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. 

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.

More information about the Twisted-Python mailing list