There is the global resource to manage in MagickWand API. This module implements automatic global resource management through reference counting.
Instantiates the MagickWand API.
Warning
Don’t call this function directly. Use increment_refcount() and decrement_refcount() functions instead.
Cleans up the MagickWand API.
Warning
Don’t call this function directly. Use increment_refcount() and decrement_refcount() functions instead.
Increments the reference_count and instantiates the MagickWand API if it is the first use.
Decrements the reference_count and cleans up the MagickWand API if it will be no more used.
Abstract base class for MagickWand object that requires resource management. Its all subclasses manage the resource semiautomatically and support with statement as well:
with Resource() as resource:
# use the resource...
pass
It doesn’t implement constructor by itself, so subclasses should implement it. Every constructor should assign the pointer of its resource data into resource attribute inside of with allocate() context. For example:
class Pizza(Resource):
'''My pizza yummy.'''
def __init__(self):
with self.allocate():
self.resource = library.NewPizza()
New in version 0.1.2.
Allocates the memory for the resource explicitly. Its subclasses should assign the created resource into resource attribute inside of this context. For example:
with resource.allocate():
resource.resource = library.NewResource()
(ctypes.CFUNCTYPE) The ctypes function that clears an exception of the resource.
Note
It is an abstract attribute that has to be implemented in the subclass.
(ctypes.CFUNCTYPE) The ctypes function that destroys the resource.
Note
It is an abstract attribute that has to be implemented in the subclass.
(ctypes.CFUNCTYPE) The ctypes function that gets an exception from the resource.
Note
It is an abstract attribute that has to be implemented in the subclass.
(ctypes.CFUNCTYPE) The ctypes predicate function that returns whether the given pointer (that contains a resource data usuaully) is a valid resource.
Note
It is an abstract attribute that has to be implemented in the subclass.
Cleans up the resource explicitly. If you use the resource in with statement, it was called implicitly so have not to call it.
Gets a current exception instance.
Returns: | a current exception. it can be None as well if any errors aren’t occurred |
---|---|
Return type: | wand.exceptions.WandException |
Raises an exception or warning if it has occurred.
Internal pointer to the resource instance. It may raise DestroyedResourceError when the resource has destroyed already.
An error that rises when some code tries access to an already destroyed resource.
Changed in version 0.3.0: It becomes a subtype of wand.exceptions.WandException.