Package omero :: Package util :: Class Resources
[hide private]
[frames] | no frames]

Class Resources

source code

Container class for storing resources which should be cleaned up on close and periodically checked. Use stop_event.set() to stop the internal thread.

Instance Methods [hide private]
 
__init__(self, sleeptime=60, stop_event=None)
Add resources via add(object).
source code
 
copyStuff(self)
Within a lock, copy the "stuff" list and reverse it.
source code
 
checkAll(self, copy)
While stop_event is unset, go through the copy of stuff and call the check method on each entry.
source code
 
removeAll(self, remove)
Finally, within another lock, call the "cleanup" method on all the entries in remove, and remove them from the official stuff list.
source code
 
add(self, object, cleanupMethod="cleanup", checkMethod="check") source code
 
cleanup(self) source code
 
safeClean(self, m) source code
 
__del__(self) source code
Method Details [hide private]

__init__(self, sleeptime=60, stop_event=None)
(Constructor)

source code 

Add resources via add(object). They should have a no-arg cleanup() and a check() method.

The check method will be called periodically (default: 60 seconds) on each resource. The cleanup method will be called on Resources.cleanup()

copyStuff(self)

source code 

Within a lock, copy the "stuff" list and reverse it. The list is reversed so that entries added later, which may depend on earlier added entries get a chance to be cleaned up first.

Decorators:
  • @locked

checkAll(self, copy)

source code 

While stop_event is unset, go through the copy of stuff and call the check method on each entry. Any that throws an exception or returns a False value will be returned in the remove list.

removeAll(self, remove)

source code 

Finally, within another lock, call the "cleanup" method on all the entries in remove, and remove them from the official stuff list. (If stop_event is set during execution, we return with the assumption that Resources.cleanup() will take care of them)

Decorators:
  • @locked

add(self, object, cleanupMethod="cleanup", checkMethod="check")

source code 
Decorators:
  • @locked

cleanup(self)

source code 
Decorators:
  • @locked