Skip to content

Commit

Permalink
remove timeout support for now because it breaks multithreading
Browse files Browse the repository at this point in the history
  • Loading branch information
pirate committed Oct 5, 2024
1 parent 7647d37 commit 78f1485
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pydantic_pkgr/binprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import operator
import platform
import subprocess
import signal

from typing import Callable, Iterable, Any, Optional, List, Dict, ClassVar, cast
from pathlib import Path
from subprocess import run, CompletedProcess
Expand Down Expand Up @@ -321,8 +321,9 @@ def call_handler_for_action(self, bin_name: BinName, handler_type: HandlerType,
def timeout_handler(signum, frame):
raise TimeoutError(f'{self.__class__.__name__} Timeout while running {handler_type} for Binary {bin_name}')

signal.signal(signal.SIGALRM, handler=timeout_handler)
signal.alarm(timeout)
# signal ONLY WORKS IN MAIN THREAD, not a viable solution for timeout enforcement! breaks in prod
# signal.signal(signal.SIGALRM, handler=timeout_handler)
# signal.alarm(timeout)
try:
if not func_takes_args_or_kwargs(handler_func):
# if it's a pure argless lambdas, dont pass bin_path and other **kwargs
Expand All @@ -333,8 +334,8 @@ def timeout_handler(signum, frame):
return handler_func(bin_name, **kwargs)
except TimeoutError:
raise
finally:
signal.alarm(0)
# finally:
# signal.alarm(0)

def setup_PATH(self):
for path in reversed(self.PATH.split(':')):
Expand Down

0 comments on commit 78f1485

Please sign in to comment.