lessthanoptimal / PyBoof

Python wrapper around the BoofCV Computer Vision Library
Apache License 2.0
67 stars 12 forks source link

ValueError: signal only works in main thread #7

Closed GokulNC closed 4 years ago

GokulNC commented 4 years ago

Line: https://github.com/lessthanoptimal/PyBoof/blob/be6fec7/pyboof/__init__.py#L80

Reason: I am trying to use this library in a GUI application that I am creating.

Solution: Probably wrap it around a try-catch?

lessthanoptimal commented 4 years ago

I ended up doing try-catch and that seems to get rid of any error. Both of these fixes plus another one have been released under 0.36.1

GokulNC commented 4 years ago

Thanks @lessthanoptimal . But what I indicated was, the signal.signal(signal.SIGINT, signal_handler) itself does not work and crashes when not running in the main thread.

I was using this library in GUI application, which uses a separate UI thread to run things. UI threads cannot use the signal module, because of which we get the error: ValueError: signal only works in main thread

The solution for now would be to do the following:

try:
    signal.signal(signal.SIGINT, signal_handler)
except ValueError as e:
    print(e)
    print('Ignoring Ctrl+C signals')