dattalab-6-cam / multicamera_acquisition

Synchronized machine vision acquisition across multiple cameras using an arduino (Supports FLIR and Basler)
MIT License
5 stars 5 forks source link

Elegant interrupt #45

Closed calebweinreb closed 7 months ago

calebweinreb commented 7 months ago

Corrects an issue with keyboard interrupt. In the current version of the code in main, a keyboard interrupt simultaneously interrupts the main thread and also all subprocesses. This is bad and not how the code is designed to work! This PR puts all processes in their own process group which prevents them from hearing the keyboard interrupt.

This PR should be merged after https://github.com/dattalab-6-cam/multicamera_acquisition/pull/44

calebweinreb commented 7 months ago

I've only tested this on ubuntu

jonahpearl commented 7 months ago

I see the problem here — you want the video writers to exit gracefully and close their video files, etc, so you only want the interrupt to apply to the main loop. Cool.

I'm confused though by what you explained here vs. what the code says.

The code has:

# Set the process group ID to to the process ID so it is affected by the main process's stop signal
os.setpgid(0, 0)

("so it is affected...")

but above it seems like you want them to not be affected. Pls explain?

calebweinreb commented 7 months ago

Yes sorry should be so it "isn't" affected.