New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
servicemanager LogInfoMsg and LogErrorMsg are crashing #2155
Comments
I'm seeing the same behaviour, though in my case the log is visible in the event viewer |
I am seeing this same behavior: calling LogInfoMsg results in the message being logged to the Windows Application log as expected, but then the app crashes with no exception or error message in the console. However, there are two log entries written to the Windows Application log: Error 2/10/2024 8:29:48 AM Application Error 1000 (100) Here are the details for the Application Error: Log Name: Application And here are the details from the Windows Error Reporting entry: Log Name: Application Problem signature: Attached files: These files may be available here: Analysis symbol: |
I'm experiencing the same issue with python 3.12.1 Here is the code I'm using: # Code is lifted from this blog post:
# https://metallapan.se/post/windows-service-pywin32-pyinstaller/
import sys
import time
import servicemanager # Simple setup and logging
import win32service # Events
import win32serviceutil # ServiceFramework and commandline helper
# sys.path.insert(0, "..")
# from mylibrary import ProprietaryClass
# from mylibrary.subdir import MyLib_Constants
class MyService:
"""Silly little application stub"""
def stop(self):
"""Stop the service"""
self.running = False
def run(self):
"""Main service loop. This is where work is done!"""
self.running = True
# secret = ProprietaryClass()
while self.running:
time.sleep(10) # Important work
# secret_result = secret.hello_world()
servicemanager.LogInfoMsg(f"{secret_result} {MyLib_Constants}")
class MyServiceFramework(win32serviceutil.ServiceFramework):
_svc_name_ = 'MyService'
_svc_display_name_ = 'My Service display name'
def SvcStop(self):
"""Stop the service"""
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
self.service_impl.stop()
self.ReportServiceStatus(win32service.SERVICE_STOPPED)
def SvcDoRun(self):
"""Start the service; does not return until stopped"""
self.ReportServiceStatus(win32service.SERVICE_START_PENDING)
self.service_impl = MyService()
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
# Run the service
self.service_impl.run()
def init():
if len(sys.argv) == 1:
servicemanager.Initialize()
servicemanager.PrepareToHostSingle(MyServiceFramework)
servicemanager.StartServiceCtrlDispatcher()
else:
win32serviceutil.HandleCommandLine(MyServiceFramework)
if __name__ == '__main__':
init() |
I am experiencing the same issue. Is this the correct forum to post on? If it is then attached inline are the contents of the associated Report.wer file:
|
First of all, thank you for the great library and the effort you put in!
I'm using
I ran into an issue after updating a Windows background service from Py3.11 to Py3.12
Using the servicemanager.LogInfoMsg function in Python 3.12 may result in a C-level crash, and it cannot be caught as an exception. No log visible in the Windows Event Viewer.
The same sequence of commands with Python 3.11 works properly.
Log is visible in Windows Event Viewer.
Not sure if this data is helpful: Starting my entire application, I see such information in the Event Viewer as error.
The text was updated successfully, but these errors were encountered: