Why is the Runner stuck on "Executing task..." and how to fix it?

Why is the Runner stuck on "Executing task..." and how to fix it?

Overview

Occasionally, the BotCity Runner may appear stuck after retrieving a new task from the queue. In these cases, the status remains as:

WarningExecuting task...

and the automation does not actually start until the Runner is manually restarted.


Likely Cause

This issue is often caused by resources not being properly released at the end of the previous automation. When the script tries to access those same resources again, the operating system may block the action, believing the resources are still in use.


Common Example: WebDriver

One of the most frequent scenarios involves the WebDriver used in web automation:

  • If the WebDriver instance is not terminated properly, it may remain running in the background.

  • This leads to conflicts during the next execution attempt and can cause the Runner to freeze.


Ensure Proper Cleanup of Resources

To avoid this issue, it’s important to include code that reliably releases all allocated resources, even in the event of an exception.

For example, in Python:


  1. from selenium import webdriver driver = webdriver.Chrome()
  2. try:
  3. # your automation logic
  4. pass
  5. finally:
  6. driver.quit() # Ensures the WebDriver is closed

Using try...finally blocks or context managers will help maintain a clean environment for each task execution.


Task Finalization and Reporting to BotCity Maestro

Once a task is retrieved by the BotCity Runner, it transitions to the Running status. It is the developer's responsibility to inform BotCity Maestro about the final outcome of that task using the Maestro SDK.

Doing so allows for:

  • Accurate task tracking

  • Visibility into task outcomes for stakeholders

  • Metrics that can be analyzed in BotCity Insights


Supported Task Statuses

You can finalize a task with one of the following statuses:

  • SUCCESS: Task completed successfully.

  • FAILED: Task failed to complete.

  • PARTIALLY_COMPLETED: Task completed some, but not all steps.

Example: Reporting Task Completion and Metrics

In Python:

  1. maestro.finish_task(
  2. task_id=task.id,
  3. status=AutomationTaskFinishStatus.SUCCESS,
  4. message="Tarefa foi concluída com sucesso.",
  5. total_items=100, # Total de itens processados
  6. processed_items=90, # Itens processados com sucesso
  7. failed_items=10 # Itens processados com falha
  8. )

You can define what an "item" means in your automation (e.g., a file, a record, an email, etc.) and track performance accordingly.

This feature is tightly integrated with BotCity Insights, which provides real-time dashboards and performance metrics for your RPA initiatives.


Additional Tip

If the Runner appears to be stuck, always check the generated log.txt file. This file often contains useful exception traces or system messages that can help pinpoint the exact issue during the preparation or execution phase.


Conclusion

When the Runner is stuck at "Executing task...", it’s often due to leftover system resources or an improperly finalized previous execution. Ensuring proper cleanup of all resources and reporting the task status via the Maestro SDK not only prevents these issues but also contributes to more effective task monitoring and analytics through BotCity Insights.