genicam / harvesters

Image Acquisition Library for GenICam-based Machine Vision System
Apache License 2.0
502 stars 86 forks source link

Exception when running harvesters with HARVESTERS_LOG_BUFFER_MANIPULATION enabled #282

Closed StefanD986 closed 2 years ago

StefanD986 commented 2 years ago

Describe the Bug When running Harvesters with the environment variable HARVESTERS_LOG_BUFFER_MANIPULATION set to True, Harvesters will throw an exception.

To Reproduce Steps to reproduce the behavior:

  1. Set environment variable HARVESTERS_LOG_BUFFER_MANIPULATION to True
  2. Copy the minimal example script attached at the end of this issue and adapt the path to the cti file!
  3. Run the minimal example script
  4. Observe log output

Expected Behavior No errors

Actual Behavior The following error message can be seen:

Traceback (most recent call last):
  File "C:/Users/Stefan/AppData/Roaming/JetBrains/PyCharm2021.3/scratches/scratch_22.py", line 31, in <module>
    main()
  File "C:/Users/Stefan/AppData/Roaming/JetBrains/PyCharm2021.3/scratches/scratch_22.py", line 23, in main
    pass
  File "c:\users\stefan\pycharmprojects\harvesters\src\harvesters\core.py", line 1160, in __exit__
    self.queue()
  File "c:\users\stefan\pycharmprojects\harvesters\src\harvesters\core.py", line 1257, in queue
    _family_tree(self._buffer.module.parent)
  File "C:\Users\Stefan\.venvs\fipy38\lib\site-packages\genicam\gentl.py", line 4260, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, Buffer, name)
  File "C:\Users\Stefan\.venvs\fipy38\lib\site-packages\genicam\gentl.py", line 93, in _swig_getattr
    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'Buffer' object has no attribute 'module'

Configuration

Reproducibility I bisected through the harvesters commits, and the first commit that shows this issue is 3d579a7dc917f7bb25333997cd9ac5b8cd29d5f0

This phenomenon can be reproduced by other versions:

Actions You Have Taken

Additional context

import logging

from harvesters.core import Harvester, ImageAcquirer

FORMAT = '%(name)s - %(asctime)s: %(message)s'
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
logger = logging.getLogger('test_application')

def main():
    h = Harvester(logger=logging.getLogger("harvesters"))

    h.add_file(
        "!!!!CHANGE_ME!!!!/mvGenTLProducer.cti"
    )
    h.update()

    logger.info(f"{h.device_info_list=}")

    ia = h.create_image_acquirer(0)
    ia.start_acquisition()

    with ia.fetch_buffer() as buffer:
        pass

    ia.stop_acquisition()  # Harvesters will lock up here.

    ia.destroy()
    h.reset()

if __name__ == '__main__':
    main()
kazunarikudo commented 2 years ago

@StefanD986 Hi, thank you for the report. I will fix that. Regards, Kazunari.