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
andstderr
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for arb_launcher-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 332693dc1bca85ca4eb6bab8f6e7772c9d9ae610061327dc37a5064eb910d01d |
|
MD5 | 5e436c6dfd98a0c3c0c40b8b0bd1bce8 |
|
BLAKE2b-256 | c102ec07eba89d5f027c7b1b09a9494793874438b1922a40376959d6804b4e8d |