RuntimeError('threads can only be started once',)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- backend, networking
Research direction
Start at WebSocketPlugin.start and the websocket manager lifecycle shown in the report, then reproduce the failure by restarting the CherryPy server through runpy.run_module. Trace why the manager is started again after the first instance exits; done means websocket-enabled server restarts without the RuntimeError and without leaving the existing cleanup behavior broken.
Written by the indexing model from the issue text.
Description
Hi,
I am having this strange problem, I am writing tests on restarting a websocket enabled CherryPy server, and for some reason, when I by using runpy.run_module starts a new process instance, I get the "threads can only be started once"-error. But strangely, not in the first instance, which I am careful to properly clean up. Not sure how anything could be carried over to the new process, but I started barking up every tree in the end.
So this is the initialization:
-
I have these in the config for the relevant path:
"tools.websocket.on": True, "tools.websocket.handler_cls": MessageWebSocket -
I start the engine like this, fairly conventional, I'd think:
cherrypy._global_conf_alias.update(_web_config) WebSocketPlugin(cherrypy.engine).subscribe() # If I remove this row, CherryPy restart nominally cherrypy.tools.websocket = WebSocketTool() cherrypy.quickstart(_root, "/", _web_config) -
And then I get this 'threads can only be started once', error in WebSocketPlugin, when it called start, I have added a condition there to just make it work for now, obviously that is not a long-term solution:
def start(self): self.bus.log("Starting WebSocket processing") self.bus.subscribe('stop', self.cleanup) self.bus.subscribe('handle-websocket', self.handle) self.bus.subscribe('websocket-broadcast', self.broadcast) if not self.manager._started.is_set(): # this row added by me self.manager.start()
Any ideas? It seems very strange that only web socket would fail, could it be that it doesn't release something properly in the first process instance? Which has already called os._exit() by this time, and I get no issues with sockets kept open either.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 285
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Lawouach/WebSocket-for-Python
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Lawouach/WebSocket-for-Python#300 ·
-
question
Lawouach/WebSocket-for-Python#297 · 2 comments · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
Lawouach/WebSocket-for-Python#296 ·
-
Lawouach/WebSocket-for-Python#280 · 1 comment · 1 assignee ·
-
Setup new CI Open
Lawouach/WebSocket-for-Python#275 · 1 assignee ·
All issues in Lawouach/WebSocket-for-Python
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·