Skip to content

Commit

Permalink
Merge pull request #107 from livechat/API-13015/fix-rtm-repsonses-han…
Browse files Browse the repository at this point in the history
…dling

check if push type is equal to response in WebsocketClient send method
  • Loading branch information
zuczkows authored Aug 18, 2023
2 parents e59cf6c + e19850c commit 7acc914
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.

### Bugfixes
- Fix HTTP request type for `get_product_source` method in Configuration API v3.5 and v3.6.
- Fix an issue related to fetching responses in RTM.

## [0.3.6] - 2023-03-09

Expand Down
8 changes: 5 additions & 3 deletions livechat/utils/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ def send(self,
if not self.sock or self.sock.send(request_json, opcode) == 0:
raise WebSocketConnectionClosedException(
'Connection is already closed.')
while not (response := next((item for item in self.messages
if item.get('request_id') == request_id),
None)) and response_timeout > 0:
while not (response := next(
(item
for item in self.messages if item.get('request_id') == request_id
and item.get('type') == 'response'),
None)) and response_timeout > 0:
sleep(0.2)
response_timeout -= 0.2
self.logger.info(f'\nRESPONSE:\n{json.dumps(response, indent=4)}')
Expand Down

0 comments on commit 7acc914

Please sign in to comment.