Free debugging kills another day (Old code adapter grows yet another barnacle...)


Today was largely a blowout. After spending an hour or two reviewing and trying to plan out the hotspot project I realised I wasn't functional and took a nap (didn't sleep well last night). Nap turned into 3 hours of not sleeping, so got up and started working on a bug Bryan had submitted.

Just checked in the final fixes half an hour ago.

Basically, the old Cinemon code was written to be blocking (it was running in a multi-threaded server). It used page templates, which don't know about Twisted's deferred objects and did blocking database queries right in the middle of the code.

When Tim asked that I stop using the page-template-base webui so that he would feel more comfortable working with my code (webui was basically wxoo for ZPT) I switched to using Nevow (Twisted's new web framework). However, in one place, editing user objects, I kept the old webui code, as it would have been too much work to rewrite it for the demo.

Problem is, that put database-dependent code in the main thread (whereas every other database operation happens in the explicit database thread). Some time ago I was trying to track down why we were getting database hangs, so I made it impossible to run database operations in the main thread. Didn't find any main-thread database operations back then, but I left the change in just in case. Today it triggered on the (rather infrequently used) user-editing page.

Spent quite a bit of time trying to figure out how to make Zope3 page templates deferred aware. Eventually had to give up, it's all done with exec-ing code that assumes it will write results to stdout. No clean way to teach it about getting deferred objects, suspending operation and then resuming when the deferred returns. Final solution was to push the entire user-editing framework into the database thread... not ideal, but then it's just legacy code anyway.

Should release webui some day I suppose. After all, most of Tim's objection to it seemed to be that it was "nonstandard"...

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.