Skip to content

fix: run_forever() now waits for thread completion before returning (closes #152)#302

Open
botbikamordehai2-sketch wants to merge 1 commit into
Lawouach:masterfrom
botbikamordehai2-sketch:fix/issue-152-1779954830
Open

fix: run_forever() now waits for thread completion before returning (closes #152)#302
botbikamordehai2-sketch wants to merge 1 commit into
Lawouach:masterfrom
botbikamordehai2-sketch:fix/issue-152-1779954830

Conversation

@botbikamordehai2-sketch
Copy link
Copy Markdown

What

run_forever() was polling self.terminated in a loop and could return before the websocket's closed() method had finished executing. This is because client_terminated and server_terminated are set to True in websocket.py before closed() is called, so self.terminated returns True prematurely.

Fix

Instead of polling self.terminated, run_forever() now simply calls self._th.join() which blocks until the worker thread has fully completed — including after closed() returns. This is simpler, more correct, and avoids the race condition entirely.

Closes #152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run_forever() terminates too early

1 participant