{"library":"oslo-service","title":"Oslo Service","description":"oslo.service is a Python library that provides a robust framework for defining and running long-running services within the OpenStack ecosystem. It encapsulates patterns for service management, including handling concurrency, periodic operations, WSGI applications, and integration with systemd. The library is actively maintained as part of the OpenStack Oslo project, with version 4.5.1 being the latest as of February 2026, and receives regular updates.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install oslo-service"],"cli":null},"imports":["from oslo_service import service","from oslo_config import cfg"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom oslo_config import cfg\nfrom oslo_service import service\n\n# Define a simple configuration option\nservice_opts = [\n    cfg.IntOpt('workers', default=1, min=1, help='Number of worker processes')\n]\nCONF = cfg.CONF\nCONF.register_opts(service_opts, group='my_service')\n\nclass MyService(service.ServiceBase):\n    def __init__(self, conf):\n        super().__init__(conf)\n        self.conf = conf\n        self.should_stop = False\n        print(f\"Service initialized with {self.conf.my_service.workers} workers.\")\n\n    def start(self):\n        print(f\"Service worker {os.getpid()} starting...\")\n        # Simulate some work\n        # In a real service, this would be a long-running loop or event listener\n\n    def stop(self):\n        self.should_stop = True\n        print(f\"Service worker {os.getpid()} stopping...\")\n\n    def wait(self):\n        # In a real service, this would block until stop() is called\n        import time\n        while not self.should_stop:\n            time.sleep(0.1)\n\ndef main():\n    CONF(args=[], project='my_app') # Pass empty args to avoid argparse errors if not parsing CLI\n    \n    # Instantiate your service\n    my_service_instance = MyService(CONF)\n\n    # Launch the service with workers\n    # Note: oslo.service's launch function creates a Launcher internally\n    # and manages worker processes if `workers` > 1.\n    # For a simple example, we often directly call the Service's methods.\n    # For multi-process, `service.launch` is key.\n    launcher = service.launch(CONF, my_service_instance, workers=CONF.my_service.workers)\n    print(f\"Launcher started for PID {os.getpid()} with {CONF.my_service.workers} workers.\")\n\n    # Wait for the service to complete (e.g., via signal handler or internal logic)\n    launcher.wait()\n    print(\"All services stopped.\")\n\nif __name__ == '__main__':\n    # To run this, you might need to install oslo.config and oslo.service\n    # and ideally run with python -m your_script_name\n    # This example demonstrates the basic structure, but running actual\n    # multi-worker services requires more robust signal handling and process management\n    # which oslo.service provides internally.\n    main()\n","lang":"python","description":"This quickstart demonstrates how to define a basic service using `oslo_service.service.ServiceBase` and launch it with `oslo_service.service.launch`. It includes integration with `oslo_config` for defining and reading configuration options, such as the number of worker processes. The `start`, `stop`, and `wait` methods illustrate the service lifecycle.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"4.3.0","pypi_latest":"4.5.1","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":6.4,"avg_import_s":1.25,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":1.03,"mem_mb":18.7,"disk_size":"59.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":6.2,"import_time_s":0.79,"mem_mb":18.7,"disk_size":"58M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":1.47,"mem_mb":21,"disk_size":"66.4M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":6.2,"import_time_s":1.32,"mem_mb":21,"disk_size":"65M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":1.59,"mem_mb":21.3,"disk_size":"66.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":6.1,"import_time_s":1.61,"mem_mb":21.3,"disk_size":"65M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":1.5,"mem_mb":22.1,"disk_size":"66.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":6,"import_time_s":1.46,"mem_mb":22.1,"disk_size":"64M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":0.87,"mem_mb":16.1,"disk_size":"60.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"oslo-service","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":7.3,"import_time_s":0.9,"mem_mb":16.1,"disk_size":"60M"}]}}