twisted much?

David Allouche david at allouche.net
Tue Jun 14 18:16:59 BST 2005


On Mon, 2005-06-13 at 12:50 -0400, Aaron Bentley wrote:
> So we're considering using asynccore and asyncchat, which are part of
> the standard Python distribution.  What would make Twisted better for
> the purpose?

I am not familiar with asyncore programming, so I might be wrong, but
there are three inter-related reasons I can see.

      * It does not allow you to defer tasks to an event loop that is
        already running.
      * It does not provide facilities for voluntary scheduling.
      * It does not offer a standard framework for writing asynchronous
        API.

You may also consider the fact that Twisted is being considered for
inclusion in the Python distribution.

> >      2. Providing a fully asynchronous bzr API (doing voluntary
> >         scheduling when not network-bound) would very much simplify the
> >         implementation of a good GUI, that must stay responsive under
> >         heavy load, and a smart server, that is a network-centric
> >         application.
> 
> I'd certainly want to provide a fully-synchonous API as well.

It is easy to provide a synchronous API as a wrapper over a Twisted
asynchronous API, since the reactor (main loop handler) can be started
and stopped at will.

But the opposite is not true, it's not easy to provide an asynchronous
API as a wrapper over a synchronous API. You have you resort to threads
or processes to do that, and that's a lot of hair.

> How does this benefit a smart server?

In part for the same reasons as it benefits a GUI. A server is a
long-running interactive process where response time must be kept low,
so it would benefit from voluntary scheduling.

Also, because a smart server may want to perform network operations
while handling incoming requests. An interactive patch-queue manager
would need to pull remote branches in response to merge requests. As I
understand it, asyncore does not allow you to defer new asynchronous
operations (like pulling remote branches) to a currently running event
loop (the main loop of the server).

Though I dislike the additional complexity and big dependency, I think
that using an asynchronous framework (not library) is going to be
needed.
-- 
                                                            -- ddaa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050614/e2269211/attachment.pgp 


More information about the bazaar mailing list