Unbound names in __del__

Torsten Bronger bronger at physik.rwth-aachen.de
Sat Jun 18 13:15:54 EDT 2005


Hallöchen!

Peter Hansen <peter at engcorp.com> writes:

> Torsten Bronger wrote:
>
>>     keithley = GpibInstrument(14)
>>     keithley.write("*IDN?")
>>     print keithley.read()
>>
>> A keithley.close() would be a wart in my opinion; instead I want
>> to hide the whole session thing from the programmer.  Besides, I
>> haven't yet given up the hope that the issues with __del__ can be
>> tackled.
>
> At least one alternative comes to mind.  Have the GpibInstrument
> class (or its module) register an atexit() method, and have the
> constructor for that class track all instances.  On shutdown, the
> atexit method goes through all instruments that are still open and
> issues the .close() requests, or whatever you do in the __del__
> now.

However, this doesn't close sessions while the program is running.
If the programmer has the above code in a function which is called
repeatedly, he may run into trouble.  IIRC my current VISA DLL has
only 256 session slots.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus



More information about the Python-list mailing list