def __del__(self): # if this is a consumer, unlock the queue if not self._producer: # release the lock if self._lockFile is not None: self._lockFile.close() # base class del Queue.__del__(self)