You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:\Users\Nobody\miniconda3\Lib\site-packages\win32\lib\win32serviceutil.py", line 1071, in SvcRun
self.SvcDoRun()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\python_winsvc.py", line 111, in SvcDoRun
WirelessNetworkMonitor.main()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\WirelessNetworkMonitor.py", line 237, in main
start_server(scan, debug=config["debug"], port=config["port"])
File "C:\Users\Nobody\miniconda3\Lib\site-packages\pywebio\platform\tornado.py", line 273, in start_server
set_ioloop(tornado.ioloop.IOLoop.current()) # to enable bokeh app
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\site-packages\tornado\ioloop.py", line 274, in current
loop = asyncio.get_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\events.py", line 699, in get_event_loop
self.set_event_loop(self.new_event_loop())
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\events.py", line 720, in new_event_loop
return self._loop_factory()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\windows_events.py", line 316, in __init__
super().__init__(proactor)
File "C:\Users\Nobody\miniconda3\Lib\asyncio\proactor_events.py", line 643, in __init__
signal.set_wakeup_fd(self._csock.fileno())
ValueError: set_wakeup_fd only works in main thread of the main interpreter
The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:\Users\Nobody\miniconda3\Lib\site-packages\win32\lib\win32serviceutil.py", line 1071, in SvcRun
self.SvcDoRun()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\python_winsvc.py", line 111, in SvcDoRun
WirelessNetworkMonitor.main()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\WirelessNetworkMonitor.py", line 237, in main
start_server(scan, debug=config["debug"], port=config["port"])
File "C:\Users\Nobody\miniconda3\Lib\site-packages\pywebio\platform\flask.py", line 181, in start_server
app.run(host=host, port=port, debug=debug, threaded=True, use_evalex=False, **flask_options)
File "C:\Users\Nobody\miniconda3\Lib\site-packages\flask\app.py", line 662, in run
run_simple(t.cast(str, host), port, self, **options)
File "C:\Users\Nobody\miniconda3\Lib\site-packages\werkzeug\serving.py", line 1115, in run_simple
run_with_reloader(
File "C:\Users\Nobody\miniconda3\Lib\site-packages\werkzeug\_reloader.py", line 452, in run_with_reloader
signal.signal(signal.SIGTERM, lambda *args: sys.exit(0))
File "C:\Users\Nobody\miniconda3\Lib\signal.py", line 58, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: signal only works in main thread of the main interpreter
改用django,报错
The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:\Users\Nobody\miniconda3\Lib\site-packages\win32\lib\win32serviceutil.py", line 1071, in SvcRun
self.SvcDoRun()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\python_winsvc.py", line 111, in SvcDoRun
WirelessNetworkMonitor.main()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\WirelessNetworkMonitor.py", line 237, in main
start_server(scan, debug=config["debug"], port=config["port"])
File "C:\Users\Nobody\miniconda3\Lib\site-packages\pywebio\platform\django.py", line 214, in start_server
http_server.listen(port, address=host)
File "C:\Users\Nobody\miniconda3\Lib\site-packages\tornado\tcpserver.py", line 191, in listen
self.add_sockets(sockets)
File "C:\Users\Nobody\miniconda3\Lib\site-packages\tornado\tcpserver.py", line 204, in add_sockets
self._handlers[sock.fileno()] = add_accept_handler(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\site-packages\tornado\netutil.py", line 247, in add_accept_handler
io_loop = IOLoop.current()
^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\site-packages\tornado\ioloop.py", line 274, in current
loop = asyncio.get_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\events.py", line 699, in get_event_loop
self.set_event_loop(self.new_event_loop())
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\events.py", line 720, in new_event_loop
return self._loop_factory()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\windows_events.py", line 316, in __init__
super().__init__(proactor)
File "C:\Users\Nobody\miniconda3\Lib\asyncio\proactor_events.py", line 643, in __init__
signal.set_wakeup_fd(self._csock.fileno())
ValueError: set_wakeup_fd only works in main thread of the main interpreter
改用aiohttp报错
The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:\Users\Nobody\miniconda3\Lib\site-packages\win32\lib\win32serviceutil.py", line 1071, in SvcRun
self.SvcDoRun()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\python_winsvc.py", line 111, in SvcDoRun
WirelessNetworkMonitor.main()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\WirelessNetworkMonitor.py", line 237, in main
start_server(scan, debug=config["debug"], port=config["port"])
File "C:\Users\Nobody\miniconda3\Lib\site-packages\pywebio\platform\aiohttp.py", line 222, in start_server
web.run_app(app, host=host, port=port)
File "C:\Users\Nobody\miniconda3\Lib\site-packages\aiohttp\web.py", line 486, in run_app
loop = asyncio.new_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\events.py", line 823, in new_event_loop
return get_event_loop_policy().new_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\events.py", line 720, in new_event_loop
return self._loop_factory()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\asyncio\windows_events.py", line 316, in __init__
super().__init__(proactor)
File "C:\Users\Nobody\miniconda3\Lib\asyncio\proactor_events.py", line 643, in __init__
signal.set_wakeup_fd(self._csock.fileno())
ValueError: set_wakeup_fd only works in main thread of the main interpreter
改用fastapi报错
The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:\Users\Nobody\miniconda3\Lib\site-packages\win32\lib\win32serviceutil.py", line 1071, in SvcRun
self.SvcDoRun()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\python_winsvc.py", line 111, in SvcDoRun
WirelessNetworkMonitor.main()
File "C:\Users\Nobody\Desktop\Programs\Projects\Python\wifi-test\WirelessNetworkMonitor.py", line 237, in main
start_server(scan, debug=config["debug"], port=config["port"])
File "C:\Users\Nobody\miniconda3\Lib\site-packages\pywebio\platform\fastapi.py", line 187, in start_server
uvicorn.run(app, host=host, port=port, **uvicorn_settings)
File "C:\Users\Nobody\miniconda3\Lib\site-packages\uvicorn\main.py", line 516, in run
config = Config(
^^^^^^^
File "C:\Users\Nobody\miniconda3\Lib\site-packages\uvicorn\config.py", line 273, in __init__
self.configure_logging()
File "C:\Users\Nobody\miniconda3\Lib\site-packages\uvicorn\config.py", line 365, in configure_logging
logging.config.dictConfig(self.log_config)
File "C:\Users\Nobody\miniconda3\Lib\logging\config.py", line 914, in dictConfig
dictConfigClass(config).configure()
File "C:\Users\Nobody\miniconda3\Lib\logging\config.py", line 563, in configure
raise ValueError('Unable to configure '
ValueError: Unable to configure formatter 'default'
环境信息
操作系统及版本: Microsoft Windows 11 x86-64 24H2 (OS内部版本26100.2454)
浏览器及版本: 【与问题无关】
Python版本: Python 3.12.3
库版本(由conda export导出): ```yaml
name: base
channels:
BUG描述
在Python中编写Windows服务的一般方法是继承
win32serviceutil.ServiceFramework
类并实现__init__(self, args), SvcDoRun(self), SvcStop(self)
方法与_svc_name_:str, _svc_display_name_:str, _svc_description_:str
属性,然后在__main__中注册该服务类并等待Windows调用。但我在
SvcDoRun()
中尝试使用pywebio.start_server()
时却在【计算机管理/事件查看器/Windows日志/应用程序】中发现如下错误信息:显然问题出在pywebio库中(我的代码中没有使用多线程)。这里也不是User's guide中提到的没有使用
register_thread(thread)
的问题(显然程序没有像文档所示的那样报pywebio.exceptions.SessionNotFoundException
异常)这恐怕是一个严重(虽然不常见,毕竟目前没有看到同样在Windows服务中使用PyWebIO的issue)且麻烦的bug,天知道为什么这个bug从asyncio波及到tornado再到pywebio。如果可以的话我希望先得到一个可用的缓解措施。
(我尝试用其他后端框架再试一遍)改用flask,报错:
改用django,报错
改用aiohttp报错
改用fastapi报错
环境信息
name: base
channels:
dependencies:
prefix: C:\Users\Nobody\miniconda3
The text was updated successfully, but these errors were encountered: