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 contain many atomic components. Asyncio makes theirs initializing a little bit complicated. It's OK, when you have 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 have to implement also graceful shutdown

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

Solution

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

Basic principles

There are 6 most significant stages of the application lifecycle:

  • on_init executes exactly once on application startup

  • pre_startup is called before event loop startup

  • on_startup is called exactly when event loop started

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

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

  • on_exit executes exactly once when application is stopping

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 worker class, which aggregate your defined callbacks and run in the right order. Depending on application type, these callbacks may be called by primary application or by you are

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.3.tar.gz (21.1 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.3-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

systempy-0.1.3-cp313-cp313-win_amd64.whl (171.8 kB view details)

Uploaded CPython 3.13Windows x86-64

systempy-0.1.3-cp313-cp313-manylinux_2_39_x86_64.whl (323.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

systempy-0.1.3-cp313-cp313-macosx_14_0_arm64.whl (314.0 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for systempy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3ba24e4d3abc56d3d209f9bfa0de662e7b3b673861305d7884ca4ce835a33a69
MD5 a432be56a098c7e7a68acec43bcc08c1
BLAKE2b-256 76f6ed1ca0b3b4ec83b89a7f6844cb8172039b6124a029acdcf7a5bd429e1555

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for systempy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c9e50feee9be1fb147f75b58ca0c96bfe87b3d887ad5deceb5928033695b1360
MD5 068f73286f9147dabbffd0f86e39d2fe
BLAKE2b-256 be74119ab3815d2b899f98b9610bbff9a2ed3b1dd864b3c1497545087b927b28

See more details on using hashes here.

File details

Details for the file systempy-0.1.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for systempy-0.1.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 86b7cc05f6b48ed58a62e80d5ddc892864780f7ca513ddc23011eb037366917e
MD5 896e48c35000b5a3e825f9f93a82cb92
BLAKE2b-256 6598dd9893964b0f1f1ded5677f8f61bf116c64a202acce55026ef75f612727a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for systempy-0.1.3-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 b5c5d9372fc0778532802656c7285b15bc426147309a969d4092295201d2ad58
MD5 b84423810f63abd14129980292243f95
BLAKE2b-256 6591e311851f3afd01a6b96e023ce59deaafbc1c3f87c8c22bf2a16ec46ba207

See more details on using hashes here.

File details

Details for the file systempy-0.1.3-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for systempy-0.1.3-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f530ebefd0ef18f16381ad5a2626303afa519672f098ceb4f042a8e67b0dfa70
MD5 8fdd1aab0be999113e0d6673f28556c3
BLAKE2b-256 f02ac2a3db7799da6c0b211305d3fefe00a44e51a6258506466f49978b2efdc8

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