twisted much?

Aaron Bentley aaron.bentley at utoronto.ca
Tue Jun 14 19:28:27 BST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Allouche wrote:
> 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.

Yes, you can.  You just add entries to asyncore.socket_map.

>       * It does not provide facilities for voluntary scheduling.
>       * It does not offer a standard framework for writing asynchronous
>         API.

Okay, so what I get from this is that it's not actually an advantage for
the purpose of speeding up 'branch', just for future work.

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

Yes, I'd be much more inclined to use Twisted if it were not an extra
dependency, but it currently still is.

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

Agreed.

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

If I were writing a smart server, I'd tend to follow the Apache model in
which each connection is handled by a different child process, so I
think synchronous operations would do a fine job.

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

Right, but it wouldn't be able to do anything useful until it had pulled
those remote branches, which seems like very linear logic to me.

So a server might itself use Twisted, but work quite well with a
synchronous api.

> Though I dislike the additional complexity and big dependency, I think
> that using an asynchronous framework (not library) is going to be
> needed.

I'd agree with 'going to be needed' (if things turn out as we expect),
but not with 'is needed'.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCryHL0F+nu1YWqI0RAoskAJ9k5nJb5mnGgJ5tW9VnMpokQaCFQACfZ4KB
WMylGKUzA7pVEwXl5sblFMs=
=3QA6
-----END PGP SIGNATURE-----




More information about the bazaar mailing list