zasync 1.0
I am happy to announce the 1.0 release of zasync. Thanks to Zope Corporation for open sourcing this Zope 2 product.
What is it?
zasync is a Zope 2 product that enables tasks to be done asynchronously. If your application needs to allow users to request that a long-running job be performed, but the user (and the Zope thread) shouldn't be tied up waiting for the job to complete, zasync is one possible solution. When the result of the job is ready, zasync supports both push and pull: the response can trigger TALES expressions run in the security context of the user who made the call, or the call manager can be polled to see if the response is ready.
What are some examples of a long-running job?
- you need to poll a database that may take a very long time to respond
- you need the app to download something off the internet, maybe big, maybe just with a big timeout
- you need to do a long-running transaction within Zope itself, but return control to the user before it completes (SUPPORTED, BUT HERE BE DRAGONS)
- you want the user to be associated with a long-running socket (e.g., a Jabber server component or a client) that should not be turned on and off within a single transaction
How does it work?
zasync is comprised of two sides: the side that lives in Zope and allows users to make asynchronous calls and poll for results; and the worker that actually does the jobs. The worker is intended to be pluggable, maybe eventually supporting workers that live within the main Zope process so that developer boxes and low-load servers can use a worker simply. However, zasync 1.0 ships with a single worker: a ZEO client driven by the Twisted reactor.
A Twisted ZEO client?
Yup. The approach has some nice scalability advantages (it can be run on a different box, for instance). It also comes with a few plugins, a couple for LDAP calls and one for calling back into Zope to do tasks. A plugin simply is a registered callable that can return a result (unlikely) or a deferred (much more likely). It includes meaty logging. The ZEO client must be configured using a standard ZConfig schema, and started using a (very bare bones at the moment) shell script. Disadvantages include the fact that you have another process to keep track of, and that you have to keep up with an additional configuration.
Are there any docs?
Yup. Of course, not as many or as high quality as I'd like. There's a README and a doctest for the call manager.
What does the future hold?
Wouldn't we all like to know. This product is in active use at the moment, so development, or at least bug fixes, are likely. I'm the supporter, not Zope Corporation, although since I work for ZC and ZC uses it right now the line blurs a bit. I hope to port this to Zope 3, refactoring as I go to take advantages of lessons learned and maybe including the simpler non-ZEO worker also so that it is easier for developers and simpler deployments to get started.
Is this in CVS?
Yup. http://cvs.zope.org/Packages/zasync/ . Shoulda been in Products: oh well. :-)