Python External Task Issue

Hi there,
I am trying to orchestrate a process in Camunda and my script is in Python. The goal is to send one single task result to Camunda and make it task complete and then there are extra scripts after to be run independent of Camunda. For example, I am sending a dictionary ( my business logic result) to Camunda then there is a user validation step done after receiving the dictionary and once the validation done, I should be done with external task.

Now my issue is that once the task is complete and I save the logs, I see the ExternalTaskWorker still running even though there is 0 task left to be processed. Here my default confing:

default_config = {
“maxTasks”: 1,
“lockDuration”: 1000,
“asyncResponseTimeout”: 5000,
“retries”: 3,
“retryTimeout”: 5000,
“sleepSeconds”: 30,
“variables”: {“response”}
}

here the piece of python where this is happening:

There are bunch of codes after line 72 to be run after the task is complete. It looks like my code does not pass this line as the ExternalTaskWorker keep sending 0 task to the process engine. Here the log:
I understand there is no task left which is good but I want this to be stopped so I can proceed to the next lines of scripts in the whole code.

2021-10-19 08:39:57,398 - Starting new HTTP connection (1): localhost:8080
2021-10-19 08:40:02,414 - http://localhost:8080 “POST /engine-rest/external-task/fetchAndLock HTTP/1.1” 200 None
2021-10-19 08:40:02,415 - [WORKER_ID:2] 0 External task(s) found for Topics: SDS.NER, Process variables: None
2021-10-19 08:40:02,416 - [WORKER_ID:2][TOPIC:SDS.NER] no External Task found for Topics: SDS.NER, Process variables: None
2021-10-19 08:40:02,416 - [WORKER_ID:2] Fetching and Executing external tasks for Topics: SDS.NER with Process variables: None
2021-10-19 08:40:02,416 - [WORKER_ID:2] Fetching and Locking external tasks for Topics: SDS.NER with Process variables: None

I appreciate if someone helps me to resolve this.
Thanks,

Hi @mocgi,

the worker should run as a background task on a server machine. He starts an infinite loop until you stop the operation system process.

Hope this helps, Ingo

Thanks Ingo! I resolved the issue by providing a way to stop the call whenever there is no task available.