Skip to main content

A package to launch and manage detached programs

Project description

arb_launcher

arb_launcher is a Python package that provides a simple yet powerful way to launch and manage detached programs and methods. It allows you to run external programs or Python methods in a completely detached process, making them independent of the parent process.

Features

  • Launch external programs and Python methods as detached processes
  • Redirect the stdout and stderr of the detached process to specific files (/dev/null by default so that the output is never printed to the console)
  • Terminate matching processes based on their names and arguments
  • Fully daemonized processes, making them independent of the parent process and allowing them to run in the background

Installation

To install arb_launcher, simply clone the repository and run the following command:

pip install arb_launcher

Usage

arb_launcher provides a simple command-line interface for launching detached programs. You can also use it as a method or library in your Python projects.

Command-Line Interface

To use the command-line interface, simply run:

arb_launcher <program> [args] [--stdout <stdout_file>] [--stderr <stderr_file>]

Simplified Launch Method

The arb_launcher package also provides a simplified method, launch_detached, for quickly launching detached programs or methods:

from arb_launcher.launcher import launch_detached

launch_detached(target, args, stdout=None, stderr=None)

target can be either a string representing the command or a callable Python method.

args should be a list of arguments, if any.

stdout and stderr are optional parameters to redirect the output to specific files.

Example

Here's an example of how to use the simplified launch_detached method to launch a detached Python method:

from arb_launcher.launcher import launch_detached

def my_method(arg1, arg2):
    # Your code here

launch_detached(my_method, args=['arg1', 'arg2'], stdout='output.log', stderr='error.log')

Python API

To use the arb_launcher package in your Python project, first import the ProgramHandler class:

from arb_launcher.program_handler import ProgramHandler

Then, create a ProgramHandler object and call the launch() method:

handler = ProgramHandler(target, args, stdout, stderr)
handler.launch()

target can be either a string representing the command or a callable Python method.

args should be a list of arguments, if any.

stdout and stderr are optional parameters to redirect the output to specific files.

Example

Here's an example of how to use the arb_launcher package to launch a detached Python method:

from arb_launcher.program_handler import ProgramHandler

def my_method(arg1, arg2):
    # Your code here

handler = ProgramHandler(my_method, args=['arg1', 'arg2'], stdout='output.log', stderr='error.log')
handler.launch()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arb_launcher-1.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

arb_launcher-1.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file arb_launcher-1.1.0.tar.gz.

File metadata

  • Download URL: arb_launcher-1.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for arb_launcher-1.1.0.tar.gz
Algorithm Hash digest
SHA256 864afbbb37981bf0231a24bdc784ea9b1c9634e081fff0420723e9c32d91f6ca
MD5 66eeb112829211a51ddb15e32cf32625
BLAKE2b-256 8a840bf750dd3a017bd1bd736bbc32239537423343077c0e50fd3a9aca437d3e

See more details on using hashes here.

File details

Details for the file arb_launcher-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for arb_launcher-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 332693dc1bca85ca4eb6bab8f6e7772c9d9ae610061327dc37a5064eb910d01d
MD5 5e436c6dfd98a0c3c0c40b8b0bd1bce8
BLAKE2b-256 c102ec07eba89d5f027c7b1b09a9494793874438b1922a40376959d6804b4e8d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page