jeffbass/imagenode

AttributeError: module 'signal' has no attribute 'SIGALRM' - receive_test.py

sbkirby opened this issue · 3 comments

This following error occurs with Windows 10 while running receive_test.py:

python imagenode\tests\receive_test.py

FPS Test Program:  imagenode\tests\receive_test.py
Option settings:
    Receive Image Type: jpg
    Show Images: True
    Test Duration: 30  seconds
First Image Received. Starting FPS timer.
Python error with no Exception handler:
Traceback error: module 'signal' has no attribute 'SIGALRM'
Traceback (most recent call last):
  File "imagenode\tests\receive_test.py", line 113, in <module>
    receive_images_forever()
  File "imagenode\tests\receive_test.py", line 96, in receive_images_forever
    signal.signal(signal.SIGALRM, timer_done)
AttributeError: module 'signal' has no attribute 'SIGALRM'

Total Number of Images received: 0
Never got any images from imagenode. Ending program.

A work-around (not a fix) for this error can be made to receive_test.py. Add the following line of code to the import section of receive_test.py.

from sys import platform

Next, replace the following lines in function receive_images_forever() with the following:

            signal.signal(signal.SIGALRM, timer_done)
            signal.alarm(TEST_DURATION)

replace with

            if platform != "win32":
                  signal.signal(signal.SIGALRM, timer_done)
                  signal.alarm(TEST_DURATION)
            else:
                  pass

Note: This will stop the error from occurring, but the FPS test will not time out. This will allow you to run the script and tune the motion detection of your YAML file.

Thanks for this bug report. I want to support Windows users and will need to remove references to the unix / Linux SIGALRM from the receive_test.py program but also from the imagenode.py call to the Patience class. The SIGALRM unix OS signal is a simple timer, but it runs asynchronously outside of Python. I will need to replace it with another algorithm.

I should have a fix for this in a few days. Your work-around removes the timer function, which should work fine until then.

I replaced the signal.SIGALRM call with a Python thread and a sleep timer. The receive_test.py program is now working OK without using signal.SIGALRM. I tested it on several Raspberry Pi's, a Linux laptop and a Mac. Worked fine on those. I don't have a Windows machine to check it on Windows. Could you check if receive_test.py works on Windows OK now? Thanks.

Hey Jeff,
It appears to be working fine in Windows.
Thanks