[Twisted-Python] Unruly Callback Code

Justin Johnson justinjohnson at fastmail.fm
Wed Aug 6 06:03:42 MDT 2003


Thanks for all your help.

On Wed, 6 Aug 2003 11:08:23 +0300, "Tommi Virtanen"
<tv at twistedmatrix.com> said:
> On Tue, Aug 05, 2003 at 12:32:06PM -0600, Justin Johnson wrote:
> > 		def gotObject(perspective, vobs, group, original_site, sites):
> > 			d = perspective.callRemote("mkvob", vobs, group)
> > 			d.addCallback(renameReplica, perspective, vobs, original_site)
> > 			d.addCallback(mkRepExport, perspective, vobs, sites)
> > 			d.addCallback(mkRepImport, perspective, vobs, sites)
> > 			d.addErrback(log.err)
> > 			d.addBoth(_stop)
> > 			return d
> > 
> > 		# Connect to the server and start the chain of deferreds
> > 		d = self.connectToServer(config.siteToServer[original_site])
> > 		d.addCallback(gotObject, vobs, group, original_site, sites)
> > 		reactor.run()
> 
> 	I'd do stopping and error handling near reactor.run()
> 
> 		def gotObject(perspective, vobs, group, original_site, sites):
> 			d = perspective.callRemote("mkvob", vobs, group)
> 			d.addCallback(renameReplica, perspective, vobs, original_site)
> 			d.addCallback(mkRepExport, perspective, vobs, sites)
> 			d.addCallback(mkRepImport, perspective, vobs, sites)
> 			return d
> 
> 		# Connect to the server and start the chain of deferreds
> 		d = self.connectToServer(config.siteToServer[original_site])
> 		d.addCallback(gotObject, vobs, group, original_site, sites)
> 		d.addErrback(log.err)
> 		d.addBoth(_stop)
> 		reactor.run()
> 
> -- 
> :(){ :|:&};:
> 
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python




More information about the Twisted-Python mailing list