I am calling a function named as func
for each sentence in my corpus as follows in python.
count =0
for sentence in sentences:
count += 1
results.append(func(sentence))
I want to pass the sentences that takes too long to process by using timeout (e.g., timeout after 30 seconds and print the sentence number).
I tried to use the solution mentioned in: Timeout on a function call and timeout-decorator library as well.
However, both of the solutions returned me the same error mentioned below.
signal.signal(signal.SIGALRM, handler)
AttributeError: module 'signal' has no attribute 'SIGALRM'
Is there a way to perform timeout in python 3? Please let me know if further details are needed.