jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
359 stars 59 forks source link

wait-for-event - infinite loop #87

Closed clementcz closed 4 years ago

clementcz commented 5 years ago

Hi,

I've just tested your example code "wait-for-event.py".

about this line : event_type, event_data = gp.check_result( gp.gp_camera_wait_for_event(camera, timeout))

I can be work well if the camera is defined on "raw+jpg", but it's not working if the camera is defined on jpg only (or raw only). At this stage there will be an infinite loop.

I found, if we insert this inside the while, it works better: if event_type == 1 and event_data == None: self.flag = False #to exit while loop

I don't know if it's the best solution, but it works.

jim-easterbrook commented 5 years ago

It's supposed to be an infinite loop. It's just a code snippet illustrating one use of gp_camera_wait_for_event. It should report the file captured each time the user triggers the camera, e.g. by manually pressing the shutter release.

clementcz commented 4 years ago

Oh yeah, I understand.

But if it's implemented inside a code after 'gp.GP_CAPTURE_IMAGE', the code doesn't stop.

I found the condition above, but I don't know if it's the good way to stop the infinite loop.

jim-easterbrook commented 4 years ago

A simple break instruction is a more obvious way to exit a loop.