Re: __del__ pattern?
- From: Michael Hudson <mwh@xxxxxxxxxx>
- Date: Wed, 17 Aug 2005 00:21:34 GMT
bryanjugglercryptographer@xxxxxxxxx writes:
> Chris Curvey wrote:
>> I need to ensure that there is only one instance of my python class on
>> my machine at a given time. (Not within an interpreter -- that would
>> just be a singleton -- but on the machine.) These instances are
>> created and destroyed, but there can be only one at a time.
>>
>> So when my class is instantiated, I create a little lock file, and I
>> have a __del__ method that deletes the lock file. Unfortunately, there
>> seem to be some circumstances where my lock file is not getting
>> deleted. Then all the jobs that need that "special" class start
>> queueing up requests, and I get phone calls in the middle of the night.
>
> For a reasonably portable solution, leave the lock file open.
> On most systems, you cannot delete an open file,
Uh, you can on unix -- what else did you have in mind for "most
systems"?
Cheers,
mwh
--
Well, yes. I don't think I'd put something like "penchant for anal
play" and "able to wield a buttplug" in a CV unless it was relevant
to the gig being applied for... -- Matt McLeod, asr
.
- References:
- __del__ pattern?
- From: Chris Curvey
- Re: __del__ pattern?
- From: bryanjugglercryptographer
- __del__ pattern?
- Prev by Date: Re: List copying idiom was Re: [Python-Dev] implementation of copy standard lib
- Next by Date: Re: keeping a ref to a non-member function in a class
- Previous by thread: Re: __del__ pattern?
- Next by thread: Re: __del__ pattern?
- Index(es):