Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow continues to run after cancelled on dashboard #1147

Open
kahkeong opened this issue Dec 23, 2024 · 0 comments
Open

Workflow continues to run after cancelled on dashboard #1147

kahkeong opened this issue Dec 23, 2024 · 0 comments

Comments

@kahkeong
Copy link

Description:
After cancelling a workflow on dashboard, There is a warning 'Thread 6330920960 with run id 3be4c09f-7ca1-482d-aeee-30fd50f9eb1c is still running after cancellation'. The code still continue to run until it finishes.

Logs:

[DEBUG] 🪓 -- 2024-12-23 15:34:48,817 - sending heartbeat
[INFO]  🪓 -- 2024-12-23 15:34:51,904 - rx: start step run: 3be4c09f-7ca1-482d-aeee-30fd50f9eb1c/first-python-workflow:step1
[DEBUG] 🪓 -- 2024-12-23 15:34:51,905 - tx: event: first-python-workflow:step1/1
[INFO]  🪓 -- 2024-12-23 15:34:51,905 - run: start step: first-python-workflow:step1/3be4c09f-7ca1-482d-aeee-30fd50f9eb1c
[DEBUG] 🪓 -- 2024-12-23 15:34:51,906 - tx: event: first-python-workflow:step1/1
INFO:root:executed step1
[DEBUG] 🪓 -- 2024-12-23 15:34:51,906 - start time: 0.0013298988342285156
0
[DEBUG] 🪓 -- 2024-12-23 15:34:52,826 - sending heartbeat
1
2
3
4
[DEBUG] 🪓 -- 2024-12-23 15:34:56,871 - sending heartbeat
5
[INFO]  🪓 -- 2024-12-23 15:34:57,469 - rx: cancel step run: 3be4c09f-7ca1-482d-aeee-30fd50f9eb1c
[INFO]  🪓 -- 2024-12-23 15:34:57,469 - cancel: step run:  /3be4c09f-7ca1-482d-aeee-30fd50f9eb1c
[DEBUG] 🪓 -- 2024-12-23 15:34:57,470 - cancelling step...
6
[WARNING]       🪓 -- 2024-12-23 15:34:58,471 - Thread 6330920960 with run id 3be4c09f-7ca1-482d-aeee-30fd50f9eb1c is still running after cancellation. This could cause the thread pool to get blocked and prevent new tasks from running.
7
8
[DEBUG] 🪓 -- 2024-12-23 15:35:00,933 - sending heartbeat
9
10
11
12
[DEBUG] 🪓 -- 2024-12-23 15:35:04,938 - sending heartbeat
13
14
15
16
[DEBUG] 🪓 -- 2024-12-23 15:35:08,940 - sending heartbeat
17
18
19
[DEBUG] 🪓 -- 2024-12-23 15:35:12,944 - sending heartbeat
[DEBUG] 🪓 -- 2024-12-23 15:35:16,949 - sending heartbeat
[DEBUG] 🪓 -- 2024-12-23 15:35:21,017 - sending heartbeat

Expected behaviour:
It should stop logging new numbers after the workflow is cancelled.

Worker code for reproduction:

from hatchet_sdk import Context, Hatchet, ClientConfig
from dotenv import load_dotenv
import logging

logging.basicConfig(level=logging.INFO)
LOG = logging.getLogger()

load_dotenv()
  
hatchet = Hatchet(
    debug=True,
    config=ClientConfig(
        logger=LOG,
    ),
)

 
@hatchet.workflow(name="first-python-workflow")
class MyWorkflow:
    @hatchet.step(retries=3)
    def step1(self, context: Context):
        LOG.info("executed step1")
        import time
        i = 0
        while i < 20:
            print(i)
            i += 1
            time.sleep(1)
        return {
            "result": "success"
        }
 

if __name__ == "__main__":
    worker = hatchet.worker('first-worker')
    worker.register_workflow(MyWorkflow())
    worker.start()

Configuration Details:

@kahkeong kahkeong changed the title Step continues to run after cancelled on dashboard Workflow continues to run after cancelled on dashboard Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant