Skip to content

Commit

Permalink
Resolve issue #72
Browse files Browse the repository at this point in the history
  • Loading branch information
kazunarikudo committed Dec 18, 2018
1 parent 3d1771e commit ec9fd9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
24 changes: 19 additions & 5 deletions README.rst
Expand Up @@ -615,7 +615,9 @@ The following code block shows Harvester Core is running on IPython. An acquired
In [14]: ia.destroy()
In [15]: quit
In [15]: h.reset()
In [16]: quit
(genicam) kznr@Kazunaris-MacBook:~%
####################
Expand Down Expand Up @@ -747,14 +749,26 @@ And the following code disconnects the connecting device from the image acquirer
ia.destroy()
Now you can quit the program! Please not that the image acquirer also supports the ``with`` statement. So you may write program as follows:
If you finished working with the ``Harvester`` object, then release the acquired resources calling the ``reset`` method:
.. code-block:: python
h.reset()
Now you can quit the program! Please not that ``Harvester`` and ``ImageAcquirer`` also support the ``with`` statement. So you may write program as follows:
.. code-block:: python
with h.create_image_acquirer(0) as ia:
# Work, work, and work with the ia object.
with Harvester() as h:
with h.create_image_acquirer(0) as ia:
# Work, work, and work with the ia object.
# The ia object will automatically call the destroy method
# once it goes out of the block.
# The h object will automatically call the reset method
# once it goes out of the block.
# the ia object will automatically call the destroy method.
This way prevents you forget to release the acquired external resources. If this notation doesn't block your use case then you should rely on the ``with`` statement.
***********************
Reshaping a NumPy array
Expand Down
6 changes: 0 additions & 6 deletions src/harvesters/core.py
Expand Up @@ -1385,9 +1385,6 @@ def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.__del__()

def __del__(self):
self.destroy()

@property
Expand Down Expand Up @@ -2196,9 +2193,6 @@ def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.__del__()

def __del__(self):
self.reset()

@property
Expand Down

0 comments on commit ec9fd9e

Please sign in to comment.