Skip to content
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

debug logs on message emit failure #43

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions ovos_bus_client/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,17 @@ def emit(self, message: Message):
'before emitting messages')
self.connected_event.wait()

if hasattr(message, 'serialize'):
msg = message.serialize()
else:
msg = json.dumps(message.__dict__)
try:
if hasattr(message, 'serialize'):
self.client.send(message.serialize())
else:
self.client.send(json.dumps(message.__dict__))
self.client.send(msg)
except WebSocketConnectionClosedException:
LOG.warning('Could not send %s message because connection '
'has been closed', message.msg_type)
LOG.warning(f'Could not send {message.msg_type} message because connection '
'has been closed')
except Exception as e:
LOG.exception(f"failed to emit message {message.msg_type} with len {len(msg)}")

def collect_responses(self, message: Message,
min_timeout: Union[int, float] = 0.2,
Expand Down