"Torsten Bronger" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>> 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.

> 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.

Deleting during a run is a different issue from deleting during program 
shutdown, which is where you started us.  In CPython, 'del keithley' will, 
if keithley is the last reference to the object, dependably delete and 
object, calling __del__ on the way.  For other implementations, deleting 
the last reference makes the object eligible to be deleted 'sometime' (if 
and when garbage collection happens).  So an explicit close is the only 
dependable cross-implementation method that I know of.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to