Lybic Docs

Long-running Tasks

Guide to handling long-running tasks in Lybic Sandbox

In Lybic Sandbox, you may need to run tasks that execute for extended periods, such as model training, data processing, web servers, asynchronous application environments, and more. Since the execSandboxProcess API has timeout limitations and does not support background execution, we recommend using the native task scheduling and background execution mechanisms built into the system for such tasks.

Limitations of execSandboxProcess API

The execSandboxProcess API provided by Lybic is suitable for executing short-running commands and scripts, but it has the following limitations:

  1. Timeout Limitation: Processes running longer than 5 seconds are automatically terminated
  2. Foreground Execution: Cannot run programs in the background; API calls block until the process ends
  3. Process Management: Does not support independent process management and monitoring

Native System Task Scheduling and Background Execution Mechanisms

  • Breaking timeout limitations: Tasks can run for any length of time
  • Status Monitoring: Can query task execution status and view log output
  • Process Isolation: The parent process of the task is transferred from Lybic service to the system job manager or task scheduler, independent of the API call lifecycle

On Windows, using PowerShell background tasks can solve these issues:

  • Background Execution: Tasks run as independent background jobs or scheduled tasks
  • Multiple Implementation Methods: Supports multiple approaches such as PowerShell Jobs, Scheduled Tasks, Start-Process, and more

On Linux, using systemd-run --user can solve these issues:

  • Background Execution: Tasks run as independent systemd transient units
  • Resource Management: Can set resource limits for CPU, memory, and more

On this page