function as windows service wrapper with threading
Project description
as_service
as_service is a Python package that provides a way to create Windows service.
Installation
pip install as_service
Usage
from as_service import AppServerSvc
class MyService(AppServerSvc):
_svc_name_ = "MyService"
_svc_display_name_ = "My Service"
_svc_description_ = 'Python Service Description'
def client_main(self, event:threading.Event):
while not event.is_set():
try:
with open(r"C:\test.txt", "w") as f:
f.write("hello")
time.sleep(3)
except:
import traceback
traceback.print_exc()
if __name__ == '__main__':
# elevate
# if access denied, you might have installed python from win store, it won't work with pythonservice
if not ctypes.windll.shell32.IsUserAnAdmin():
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
sys.exit(0)
try:
MyService.logger().addHandler(logging.StreamHandler())
MyService.logger().addHandler(logging.FileHandler("log.txt"))
MyService.cli()
except Exception as e:
MyService.logger().exception(e)
finally:
time.sleep(2)
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file as_service-0.1.1-py3-none-win_amd64.whl.
File metadata
- Download URL: as_service-0.1.1-py3-none-win_amd64.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d41b8b0ee9e111b6dc1ceb860dcaa11a5aaf612a85ac8bbd5698e3e0c1de3355
|
|
| MD5 |
84aaea2a4549394b9bd84e7470aa82db
|
|
| BLAKE2b-256 |
9e587d65e700afcd226753199c7ee6db163a6756fe33197353da6072d55ea798
|