Skip to main content

Python application component initialization system

Project description

systemPY

Logo

Python application component initialization system

python version downloads format Documentation Status GitHub issues Ruff Checked with mypy

Full documantation is available at Read the Docs

The problem

The regular application contains many atomic components. Asyncio makes their initializing a little bit complicated. It's OK, when you have a single entrypoint and initialize your application components via your framework. While you add new components to your application iteratively, you don't see any problem

When you create any new entrypoint, you have to think a lot, how to initialize application components again, which callbacks should be called and in which order. But it's a half of the problem! You also have to implement a graceful shutdown

The most painful part is one-time scripts. It's kind of The Banana Gorilla Problem: you just want a banana but you have to initialize a gorilla holding the banana and the entire jungle, and then gracefully shutdown it

Solution

This library allows you to implement application startup and shutdown in a declarative way. You have to implement a class for each your component, write the startup and shutdown code. Then you have to combine required components as mixins into the current application App class. Then create an instance and pass dependencies as keyword arguments. In case it's a self-hosted app you have to call the instance.run_sync() method

Note that systempy is NOT a di framework, but it may be used with any of them. Also systempy is NOT a binding to systemd, but I was inspired by it and systempy is doing similar things on a much smaller scale

Basic principles

There are 6 the most significant stages of the application lifecycle:

  • on_init is called exactly once on the application startup

  • pre_startup is called before the event loop is started

  • on_startup is called exactly when the event loop has started

  • on_shutdown is called when the application is going to shutdown or reload but the event loop is still working

  • post_shutdown is called after event loop has stopped or drained. When application is going to reload, next it would be called pre_startup

  • on_exit is called exactly once when application is going to stop

You may to create Unit classes for each your application component where you may put your code. Then you may combine these Unit class mixins into the current App class, which composes your defined callbacks and runs in the right order. Depending on application type, these callbacks may be called by primary application or by yourself

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

systempy-0.1.6.tar.gz (21.3 kB view details)

Uploaded Source

Built Distributions

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

systempy-0.1.6-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

systempy-0.1.6-cp313-cp313-manylinux_2_39_x86_64.whl (245.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

systempy-0.1.6-cp313-cp313-manylinux_2_35_x86_64.whl (242.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ x86-64

systempy-0.1.6-cp313-cp313-macosx_15_0_arm64.whl (242.6 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

systempy-0.1.6-cp312-cp312-manylinux_2_39_x86_64.whl (247.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

systempy-0.1.6-cp312-cp312-manylinux_2_35_x86_64.whl (244.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

systempy-0.1.6-cp312-cp312-macosx_15_0_arm64.whl (242.9 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

systempy-0.1.6-cp311-cp311-manylinux_2_39_x86_64.whl (238.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

systempy-0.1.6-cp311-cp311-manylinux_2_35_x86_64.whl (235.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ x86-64

systempy-0.1.6-cp311-cp311-macosx_15_0_arm64.whl (240.6 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

systempy-0.1.6-cp310-cp310-manylinux_2_39_x86_64.whl (242.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

systempy-0.1.6-cp310-cp310-manylinux_2_35_x86_64.whl (238.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

systempy-0.1.6-cp310-cp310-macosx_15_0_arm64.whl (245.4 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

systempy-0.1.6-cp39-cp39-manylinux_2_39_x86_64.whl (241.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.39+ x86-64

systempy-0.1.6-cp39-cp39-manylinux_2_35_x86_64.whl (238.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.35+ x86-64

systempy-0.1.6-cp39-cp39-macosx_15_0_arm64.whl (245.2 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

Details for the file systempy-0.1.6.tar.gz.

File metadata

  • Download URL: systempy-0.1.6.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.8

File hashes

Hashes for systempy-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b3d1eeb461c778b2ee89992fee298da08dacc52a1a07e5e2b0e7c66b81b12eb9
MD5 244d88ec0d47da46b06f7297a5418500
BLAKE2b-256 781cdc96e5afba1a5579c026a2d18f67eca0757360260676f2eedc3d01ee2d96

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: systempy-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 28.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.8

File hashes

Hashes for systempy-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d3b531d57ee5115964d9b472c65aa03a912e1b8e0c84a00ed390a2934263edd5
MD5 af06ef8419eb5173ba3764fdd402d3aa
BLAKE2b-256 2169112404c289d3f92435abf95fca617daad7d245476acd176af27e4770e713

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 e27395e2e4b38002d903d57ac31b3730066ce495904169d177b0fb938c103e89
MD5 edf78227dd2def2dc03b7d285870ac3b
BLAKE2b-256 60b2d9a212cfe5e83bddaf10452197f539309bbfaad4bd0a1319c5e23fa2dc57

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp313-cp313-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp313-cp313-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 64c8619af52637a694e861457c009ce8dec9221bd8357d95b9fe9c573ff43478
MD5 8899a2b2100fbc6963e8c801b4036963
BLAKE2b-256 b4298562e12e1d4408b1126c7046eec4ded7b200b751d6297e1d37d43ffaddaf

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c57c6a19ba44a02792453b0eef83bb4d63923dbd6fda07be5c6e9a7409614beb
MD5 e2c0a9c1e3aa16b30a869c1dd0a58a43
BLAKE2b-256 ba246a64ffe3184dc24709e61e40d88c74ccc9c9b48c0d656dc03f9dda84cbef

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 80b178638b592092d8d765c180aa643106e98e502b9413cd469a98d98eb79f67
MD5 133d7ba6ccf8e2beb7cdfed5f4f2f9e1
BLAKE2b-256 504177c1daf8f2a991c0f8cd3b3d5ea92049e37f0b2df5058100313cff896bdc

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp312-cp312-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 a61335f2ad455916ec7d14f08b90241ee97ac3a15d73b6f833d243e8279ffcfc
MD5 69808d651d6dc2ffe837a5c22d0ec693
BLAKE2b-256 a191c0cbfdefa83b71596e809b5f8905c2dfccdd98092ca0c68bd8edc69e0a98

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 32f0c8ec941f8c9e7cceeca182d7697a665b3dfb4995a5e91a01cbaec3d5d5e7
MD5 c62eee12f9b2c880cb33ca1f3931be66
BLAKE2b-256 01e274740dfefb62d91d361cb81b8ea9daad84a5aa417053564c9b3f594322ae

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 e9acdc80797c9732a22e816db0a30215f384b95963c31e62807696e41de6cad1
MD5 84a84c23123baa4beaba3c594772eabb
BLAKE2b-256 211a76266f0850a9f866a381c6266c4a98c8c220be7426cd620c833ea3dfd0ae

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp311-cp311-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp311-cp311-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 fd5e291321c381d8a6006f902c135efae95f0d581255e0badc815d47371eee08
MD5 167cb5b412f82f2f262d539117cb78b5
BLAKE2b-256 e230c8006331015019eeea8c92e40e25d478dad66c89443f08dbca799c0d8d26

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9fac68648fbeecd6e40f457c231ee0418524f862ac1a76420f68c50aeb6d0eb8
MD5 59b8886b3f5e5e23fdd92f3316988014
BLAKE2b-256 e7aefdedc825a93570f1f0372fc68c227f51ffa4360e148ae2dcbadc82ea05b4

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 eb8135cfd6b89076a8fc44b232a5694f260cd7a906914c6164ddf7a2bf0bc2c6
MD5 8e9975b8d3019dd37d7eb7090364d687
BLAKE2b-256 bd006e05cea30f1b7ebf69a409df5717730ab78794aa364a319b6ee5a8063ee4

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp310-cp310-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 47eb2f85f163829ea8b02015e9b664b3cd0fd9ed78c306c88d7ed355a67b2776
MD5 bbd5a19e408f108d35f3312653d087e4
BLAKE2b-256 2923f7b95e2a8c49ffde85305f125cd5cc08d38d81052daf3682fdb2ca008b7f

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ba8c77409f12abd8bb144c4d581094147877298d2f73824d29ecedc5c01a2ad8
MD5 562ee55542c22abe93b83b510449f668
BLAKE2b-256 f1fe9a5b8b6c87feabd261791e06b558c66520afa65171ca5238ea2b495e8a5f

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 313dc2d054d77539d03bec887bee03d8b0b0fef3e1e000d5768a60978f4bc129
MD5 1790e09746d8d4b2e9b3188aac27b064
BLAKE2b-256 7deecd24941e228f1b3e428cde22ecb307a11da2f3996e268741c66daa57782c

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp39-cp39-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp39-cp39-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 d6e3332b4b1e6df87639aced4a0fedee33897838015273a80f1d3b58060fdce7
MD5 008cf37330990ef091b8a6828e3b354d
BLAKE2b-256 f153f03f715cd8630183cf9632e50e13bda1a67fc9a8671c4884390d0bbc243d

See more details on using hashes here.

File details

Details for the file systempy-0.1.6-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for systempy-0.1.6-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 59d3796049f9439e27296f1bd43402b45b3512fa62b4fcbac3dc91bff71ba9bd
MD5 67fc7dd372c4bd0a7da55cab66d0d6d1
BLAKE2b-256 037222a266db1b62f6407d21b431eaafcb852b09ed5a3ac11a39a5db28cadf56

See more details on using hashes here.

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