Skip to content

Commit

Permalink
Feat: Killing sync threads (#323)
Browse files Browse the repository at this point in the history
* feat: thread killing

* fix: rm events

* fix: lint
  • Loading branch information
mrkaye97 authored Feb 18, 2025
1 parent 88a28ba commit 903677f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hatchet_sdk/worker/runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import ctypes
import functools
import json
import time
import traceback
from concurrent.futures import ThreadPoolExecutor
from enum import Enum
from multiprocessing import Queue
from threading import Thread, current_thread
from typing import Any, Callable, Dict, Literal, Type, TypeVar, cast, overload
from typing import Any, Callable, Dict, cast

from pydantic import BaseModel

Expand Down Expand Up @@ -421,6 +422,11 @@ async def handle_cancel_action(self, run_id: str) -> None:

# check if thread is still running, if so, print a warning
if run_id in self.threads:
thread = self.threads.get(run_id)
if thread:
self.force_kill_thread(thread)
time.sleep(1)

logger.warning(
f"Thread {self.threads[run_id].ident} with run id {run_id} is still running after cancellation. This could cause the thread pool to get blocked and prevent new tasks from running."
)
Expand Down

0 comments on commit 903677f

Please sign in to comment.