simple-winservice


Namesimple-winservice JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA simple library for creating windows services and logging using windows event log
upload_time2025-08-22 09:42:17
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseApache-2.0
keywords windows service
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

```python
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`.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "simple-winservice",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "windows, service",
    "author": null,
    "author_email": "Einar Omang <einar.omang@cognite.com>",
    "download_url": "https://files.pythonhosted.org/packages/26/36/83f0432f732e78756b593e2aa94eec26bc3c527d17a1dade8863e169cab5/simple_winservice-0.1.0.tar.gz",
    "platform": null,
    "description": "# Cognite Windows Service Library\n\nThis 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.\n\nUnlike other windows service libraries, it does not have code to actually create the windows service, again assuming that this is done externally.\n\nEvent logging uses the user provided event log source name, and logs plain text to event ID 0.\n\n## Usage\n\nSee 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.\n\n```python\nfrom simple_winservice import register_service, run_service, ServiceHandle\nfrom threading import Event\n\ntoken = Event()\n\ndef cancel_service() -> None:\n    token.set()\n\ndef service_main(handle: ServiceHandle, args: list[str]) -> None:\n    handle.event_log_info(\"Service is now running!\")\n\n    while not token.wait(1):\n        handle.event_log_info(\"Service is still running!\")\n\n    handle.event_log_info(\"Service is shutting down now\")\n\ndef main() -> None:\n    register_service(service_main, \"MyTestService\", cancel_service)\n    run_service()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Development\n\nYou 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`.\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A simple library for creating windows services and logging using windows event log",
    "version": "0.1.0",
    "project_urls": {
        "homepage": "https://cognite.com",
        "repository": "https://github.com/cognitedata/python-windows-service"
    },
    "split_keywords": [
        "windows",
        " service"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b726d1295589a20f5a6f696018682662cc212b3c99cf3961800011f5d608a774",
                "md5": "07ec23e8a9f5dbc2fedfb91d06743007",
                "sha256": "c56d09d443b63410ea7d08262d0b81a7c8634dfe35ac8fc529d5d8a16b8cd413"
            },
            "downloads": -1,
            "filename": "simple_winservice-0.1.0-cp310-cp310-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "07ec23e8a9f5dbc2fedfb91d06743007",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 145649,
            "upload_time": "2025-08-22T09:42:15",
            "upload_time_iso_8601": "2025-08-22T09:42:15.169785Z",
            "url": "https://files.pythonhosted.org/packages/b7/26/d1295589a20f5a6f696018682662cc212b3c99cf3961800011f5d608a774/simple_winservice-0.1.0-cp310-cp310-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c5bf46b37def710a1ca2b7d25ad79dd852ba6c42601cf4635b11f34586db8e17",
                "md5": "f6d5a13aebca3ef94995e6f2ae026b27",
                "sha256": "930345a73fb498996e68757088d417ce6388f3b40901d2ff69fed9a20351b193"
            },
            "downloads": -1,
            "filename": "simple_winservice-0.1.0-cp311-cp311-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "f6d5a13aebca3ef94995e6f2ae026b27",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 145414,
            "upload_time": "2025-08-22T09:42:16",
            "upload_time_iso_8601": "2025-08-22T09:42:16.267556Z",
            "url": "https://files.pythonhosted.org/packages/c5/bf/46b37def710a1ca2b7d25ad79dd852ba6c42601cf4635b11f34586db8e17/simple_winservice-0.1.0-cp311-cp311-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ebece652f57e6338235f9b740b8e832d89719966b328708ffda9fae532d4319a",
                "md5": "8a3ed758b4809b1bb41057259215a991",
                "sha256": "ca1df2824f505295144f5ae89434eb12ad074c1831d5404cba79f16db7006f03"
            },
            "downloads": -1,
            "filename": "simple_winservice-0.1.0-cp312-cp312-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "8a3ed758b4809b1bb41057259215a991",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10",
            "size": 145322,
            "upload_time": "2025-08-22T09:42:17",
            "upload_time_iso_8601": "2025-08-22T09:42:17.096829Z",
            "url": "https://files.pythonhosted.org/packages/eb/ec/e652f57e6338235f9b740b8e832d89719966b328708ffda9fae532d4319a/simple_winservice-0.1.0-cp312-cp312-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "263683f0432f732e78756b593e2aa94eec26bc3c527d17a1dade8863e169cab5",
                "md5": "19658475a16a3ef3c81336aec74f7d3d",
                "sha256": "c450c05b27e6320c536c7dfaa9df0376443496f1ea19cc02c7e92cf320ffa812"
            },
            "downloads": -1,
            "filename": "simple_winservice-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "19658475a16a3ef3c81336aec74f7d3d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 15256,
            "upload_time": "2025-08-22T09:42:17",
            "upload_time_iso_8601": "2025-08-22T09:42:17.898550Z",
            "url": "https://files.pythonhosted.org/packages/26/36/83f0432f732e78756b593e2aa94eec26bc3c527d17a1dade8863e169cab5/simple_winservice-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-22 09:42:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cognitedata",
    "github_project": "python-windows-service",
    "github_not_found": true,
    "lcname": "simple-winservice"
}
        
Elapsed time: 1.68665s