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.

    • Related Articles

    • What to do when Runner seems stuck when executing a new task?

      In sporadic situations, the Runner may seem stuck after pulling a new task for execution. In this situation, the execution is not started, and the Runner status remains as Executing task ... until the Runner is restarted. Overall, the resources used ...
    • How to fix Python environment preparation failed error

      A very common error when executing automations through the Runner is Python Environment Preparation Failed. As the name suggests, the Runner fails when trying to prepare the Python environment for the robot's execution. This error occurs in different ...
    • Keeping your remote session active when using Runner

      In some cases where a VM is used to run the automation, keeping the remote session active is necessary to avoid problems with the graphical interface, such as the OSError: screen grab failed error. This error is usually thrown when trying to perform ...
    • How to Resolve the Issue of Installation Stuck at 0% in BotCity Studio ?

      Overview If you're trying to install BotCity Studio or start the BotCity Runner and the installation gets stuck at 0%, or you experience authentication or login errors, it is very likely that your corporate environment is blocking the required ...
    • Error Running Wizard.exe: How to Fix It?

      Issue When attempting to start the installation, configuration, or authentication process of the BotCity Runner using the wizard in .exe format, you may encounter difficulties opening the file. This error usually occurs due to company security ...