-
Notifications
You must be signed in to change notification settings - Fork 6
fix: handle SSE connection state when Start events are not received #105
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,9 +128,8 @@ def run(self): | |
| time.sleep(self._options.config_polling_interval_ms / 1000.0) | ||
|
|
||
| def sse_message(self, message: ld_eventsource.actions.Event): | ||
| if self._sse_connected is False: | ||
| self._sse_connected = True | ||
| logger.info("DevCycle: Connected to SSE stream") | ||
| if not self._sse_connected: | ||
| self.sse_state(None) | ||
| logger.info(f"DevCycle: Received message: {message.data}") | ||
| sse_message = json.loads(message.data) | ||
| dvc_data = json.loads(sse_message.get("data")) | ||
|
|
@@ -145,9 +144,11 @@ def sse_message(self, message: ld_eventsource.actions.Event): | |
| def sse_error(self, error: ld_eventsource.actions.Fault): | ||
| logger.debug(f"DevCycle: Received SSE error: {error}") | ||
|
|
||
| def sse_state(self, state: ld_eventsource.actions.Start): | ||
| self._sse_connected = True | ||
| logger.info("DevCycle: Connected to SSE stream") | ||
| def sse_state(self, state: Optional[ld_eventsource.actions.Start]): | ||
| # Prevents duplicate logs when Comment events call this repeatedly | ||
| if not self._sse_connected: | ||
| self._sse_connected = True | ||
| logger.info("DevCycle: Connected to SSE stream") | ||
|
Comment on lines
152
to
155
|
||
|
|
||
| def close(self): | ||
| self._polling_enabled = False | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type signature inconsistency detected. The SSEManager constructor expects handle_state to be of type
Callable[[ld_eventsource.actions.Start], None](line 15 in sse_manager.py), but the sse_state method signature has been changed to acceptOptional[ld_eventsource.actions.Start]. The SSEManager type hints should be updated to reflect this change, usingOptional[ld_eventsource.actions.Start]instead of justld_eventsource.actions.Start.