Let's split this into another thread (was: "RE: [Webware-discuss] Re: [ZODB-Dev] Webkit Threading and ZODB 3. 3a2: problems on Windows")
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Matt > Feifarek > Sent: Thursday, February 19, 2004 3:29 PM > To: Geoffrey Talvola > Cc: WebWare mailing list > Subject: Re: [Webware-discuss] Re: [ZODB-Dev] Webkit Threading and ZODB > 3. 3a2: problems on Windows > > > Geoffrey Talvola wrote: > > >That would mean that sleep() has to be coded "defensively" so > that it still > >works properly even if awake() failed halfway through (which is > a change to > >current semantics): > > > > > I remember that this was basically the result of our discussions, yes. > At the time, I thought it was better to be defensive and notice the > occasional exception than to have unpredictable things happen because > cleanup doesn't get run. > > > def sleep(self, trans): > > if hasattr(self, '_bar'): del self._bar > > if hasattr(self, '_foo'): del self._foo > > Base.sleep(self, trans) > > > > > It's pretty easy just to set them to None. No tests required then. > That's what we do. > > >I used to not like requiring sleep() to be written in this way > but I think > >I'm changing my mind -- this may be the best way to go. I'd like to hear > >other opinions though. > > > >I usually don't even bother writing a sleep() because there's no harm in > >leaving around the values I've stored in self until the next request. > > > We often do a bunch of state-related cleanup in sleep... > > Sure, we could just clean up in the next round of awake... make sure > that sane defaults are there before we do anything. > > What about something like a database connection (oh, say, maybe a ZODB > connection ;-)? You'd need to close/release it sometime. > I'm against having to write sleep() defensively for a few reasons, but I would like to see sleep() called if awake() completes without exception. So I vote for Geoffrey's first alternate: try: self.awake(transaction) try: self.respond(transaction) finally: self.sleep(transaction) except EndResponse: pass Matt's point about closing state-related operations is big. My suspicion is that most Webware developers use awake()/sleep() to set/unset servlet variables, and don't run into any issue with missing sleep() calls. But if awake and sleep are truly paired functions, and developers code sleep() to clean up work begun in awake(), then sleep should be called in all cases if awake completes without exception. But I don't want to force sleep to run in the case of an exception during awake. My view (I'd love to hear others) is that an unhandled exception in awake() is called a bug and should be fixed in development. I don't want the framework to force me to write sleep() with extra conditional logic to avoid clobbering an exception raised from a bug I may code into awake(). my 2 cents! Ben ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
