Skip to main content

Looper is a daemonizer library, it can help you with lifecycle of your daemon.

Project description

GenesisCoreLibs Looper Documentation

Overview

GCL Looper is a Python library designed to create daemon-like services that can run indefinitely, performing tasks at regular intervals or on demand.

Usage Examples

Basic Service

  • Iterate infinitely
  • There should be at least 5 seconds between start of previous and next iteration (iter_min_period)
  • pause for 1 second between iterations (iter_pause)
from gcl_looper.services import basic

class MyService(basic.BasicService):
    def __init__(self, iter_min_period=5, iter_pause=1):
        super(MyService, self).__init__(iter_min_period, iter_pause)

    def _iteration(self):
        print("Iteration", self._iteration_number)

service = MyService()
service.start()

Finite Service without any pauses in-between

from gcl_looper.services import basic

class MyFiniteService(basic.BasicService):
    def __init__(self, iter_min_period=0, iter_pause=0):
        super(MyFiniteService, self).__init__(iter_min_period, iter_pause)
        self.countdown = 3

    def _iteration(self):
        if self.countdown > 1:
            self.countdown -= 1
        else:
            self.stop()

service = MyFiniteService()
service.start()

Public interface:

  • start(): Starts the service.
  • stop(): Stop the service.
  • _loop_iteration(): Performs one iteration of the service loop.

Implement these methods to get usable service:

  • _iteration(): This method must be implemented by subclasses to perform the actual work at each iteration.

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

gcl_looper-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gcl_looper-0.1.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file gcl_looper-0.1.0.tar.gz.

File metadata

  • Download URL: gcl_looper-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for gcl_looper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5e6f552e05a768c541bc42dcf4f5f2dd7c831319001576f1b279dace2e3622b0
MD5 5d9232a323e867a237c2604f437b19be
BLAKE2b-256 c4d9ffcf0aad6b5ff66e52cd1c833b930dbd6c454b6dd9c8d8af26fd32830321

See more details on using hashes here.

Provenance

The following attestation bundles were made for gcl_looper-0.1.0.tar.gz:

Publisher: publish-to-pypi.yml on infraguys/gcl_looper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gcl_looper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gcl_looper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for gcl_looper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11d62789cca9df02aaba456382af61ea89fd11a08a7cf5202e1678f5d8e6f448
MD5 c2c59f393f3363edc3fcb24cee145e60
BLAKE2b-256 c5314041f4c4ae2065b9fea03c975114b2479be897355465858a2d59e26b0509

See more details on using hashes here.

Provenance

The following attestation bundles were made for gcl_looper-0.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on infraguys/gcl_looper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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