def execute(self, function, **args):
while True:
tmout = False
sem.acquire()
response = Queue()
p = Process(
target=self.execute_work,
args=[function, response],
kwargs=args
)
p.start()
p.join(10)
if p.is_alive():
p.terminate()
p.join()
tmout = True
resp = response.get()
sem.release()
if tmout:
continue
resp = resp if resp != dict else resp.copy()