Cognite Windows Service Library
This is a python/rust library for running python programs as simple windows services. It supports basic event logging, though you will need to define the event message source yourself, typically through a windows installer or similar.
Unlike other windows service libraries, it does not have code to actually create the windows service, again assuming that this is done externally.
Event logging uses the user provided event log source name, and logs plain text to event ID 0.
Usage
See the python interface. Simply install the library, call register_service, and once the extractor has come somewhat online, call set_service_running on the ServiceHandle passed to the startup callback. See method docs.
from simple_winservice import register_service, run_service, ServiceHandle
from threading import Event
token = Event()
def cancel_service() -> None:
token.set()
def service_main(handle: ServiceHandle, args: list[str]) -> None:
handle.event_log_info("Service is now running!")
while not token.wait(1):
handle.event_log_info("Service is still running!")
handle.event_log_info("Service is shutting down now")
def main() -> None:
register_service(service_main, "MyTestService", cancel_service)
run_service()
if __name__ == "__main__":
main()
Development
You will need maturin, and rust/cargo, installed using rustup. To build, activate a local venv, then just run maturin develop, after which the local venv will contain an installed version of the library you can use. There's a sample service in the service_test.py file, which is intended to be run as a windows service called with entry point .../.env/Scripts/python.exe .../service_test.py more arguments here.
Release files for simple-winservice 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| simple_winservice-0.1.1.tar.gz | 15.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| simple_winservice-0.1.1-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| simple_winservice-0.1.1-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| simple_winservice-0.1.1-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| simple_winservice-0.1.1-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details |
Total release size: 595.3 kB
Release files / simple_winservice-0.1.1.tar.gz
| Download URL | simple_winservice-0.1.1.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
385a01fe2168195dccf141f47f1184f0df87076c133422ca823e4d4b8af3bf6b
|
|
BLAKE2b-256 checksum How to use checksums |
f00c17e5ac389abdf319136eb2fc6180f7f422c4377063ca55a2c4e203b342c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / simple_winservice-0.1.1-cp313-cp313-win_amd64.whl
| Download URL | simple_winservice-0.1.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 145.0 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a252e94eae1a029e9d285f33efb1e66d5c9d74776336e15c7d244820a5eee815
|
|
BLAKE2b-256 checksum How to use checksums |
c2e39fbfb4495f53f79350c66d845ee381beb1d1f2dccbf2a9c58b1336d489b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / simple_winservice-0.1.1-cp312-cp312-win_amd64.whl
| Download URL | simple_winservice-0.1.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 145.2 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
248959b741023fce355af34b5de59cb36ae22ffdd581a1b6a7e37b4ca1ea20c1
|
|
BLAKE2b-256 checksum How to use checksums |
87eefce7264f0cab08e7199de50a2b5d690428823bb0692a876a2a45f9f9b404
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / simple_winservice-0.1.1-cp311-cp311-win_amd64.whl
| Download URL | simple_winservice-0.1.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 144.8 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
80710fcd48bc253473926929e910b4dce07e2181d4dee0dbd7525dd99f5a8cf2
|
|
BLAKE2b-256 checksum How to use checksums |
db3fbaa8679362ece7b735b9325e3730bb629281d3f3d6bae3cd18a990111099
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / simple_winservice-0.1.1-cp310-cp310-win_amd64.whl
| Download URL | simple_winservice-0.1.1-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 144.8 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b32477eb7f9135b5fcd2b21e8db8d6002ad573e8bcafddf795bf6c27f8b3bdcf
|
|
BLAKE2b-256 checksum How to use checksums |
8dbb7134e01b42633b5e4b1d82a1bd4c95730fe0151043a4b5d646868c9192d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|