Как отключить функцию в Python, время ожидания меньше секунды

Specification of the problem:

Я ищу действительно большое количество строк в файле журнала и раздаю эти строки по группам для регулярных выражений (RegExses), которые я сохранил, используяre.match() функция. К сожалению, некоторые из моих RegExses слишком сложны, и Python иногда попадает в ад. Из-за этого мне нужно защитить его с каким-то таймаутом.

Problems: re.match, I'm using, is Python's function and as I found out somewhere here on StackOverflow (I'm really sorry, I can not find the link now :-( ). It is very difficult to interrupt thread with running Python's library. For this reason threads are out of the game. Because evaluating of re.match function takes relatively short time and I want to analyse with this function great amount of lines, I need some timeout function that wont't take too long to execute (this makes threads even less suitable, it takes really long time to initialise new thread) and can be set to less than one second.
For those reasons, answers here - Timeout on a function call and here - Timeout function if it takes too long to finish with decorator (alarm - 1sec and more) are off the table.

Я провел это утро в поисках решения этого вопроса, но не нашел удовлетворительного ответа.

Ответы на вопрос(1)

Ваш ответ на вопрос