Skip to content

Commit

Permalink
CR fixup: Added response_timeout parameter in open_connection methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Dębski committed Jul 25, 2024
1 parent 500ffbb commit d356f71
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 48 deletions.
3 changes: 1 addition & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ All notable changes to this project will be documented in this file.

### Added
- New `get_company_details` method in configuration-api v3.6.
- Added `response_timeout` parameter in `open_connection` methods.

### Changed
- Updated outdated packages.
- Exposed `response_timeout` parameter in `open_connection` methods.
- Changed default value of `ping_timeout` to 30 seconds.

## [0.3.9] - 2024-04-22

Expand Down
10 changes: 5 additions & 5 deletions livechat/agent/rtm/api/v33.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ def __init__(self, url: str):

def open_connection(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> None:
response_timeout: Union[float, int] = 3) -> None:
''' Opens WebSocket connection.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down
10 changes: 5 additions & 5 deletions livechat/agent/rtm/api/v34.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ def __init__(self, url: str):

def open_connection(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> None:
response_timeout: Union[float, int] = 3) -> None:
''' Opens WebSocket connection.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down
10 changes: 5 additions & 5 deletions livechat/agent/rtm/api/v35.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ def __init__(self, url: str):

def open_connection(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> None:
response_timeout: Union[float, int] = 3) -> None:
''' Opens WebSocket connection.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down
10 changes: 5 additions & 5 deletions livechat/agent/rtm/api/v36.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ def __init__(self, url: str):

def open_connection(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> None:
response_timeout: Union[float, int] = 3) -> None:
''' Opens WebSocket connection.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down
10 changes: 5 additions & 5 deletions livechat/customer/rtm/api/v33.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ def __init__(self, license_id: str, base_url: str):

def open_connection(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> None:
response_timeout: Union[float, int] = 3) -> None:
''' Opens WebSocket connection.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down
10 changes: 5 additions & 5 deletions livechat/customer/rtm/api/v34.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ def __init__(self, organization_id: str, base_url: str):

def open_connection(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> None:
response_timeout: Union[float, int] = 3) -> None:
''' Opens WebSocket connection.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down
10 changes: 5 additions & 5 deletions livechat/customer/rtm/api/v35.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ def __init__(self, organization_id: str, base_url: str):

def open_connection(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> None:
response_timeout: Union[float, int] = 3) -> None:
''' Opens WebSocket connection.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down
10 changes: 5 additions & 5 deletions livechat/customer/rtm/api/v36.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ def __init__(self, organization_id: str, base_url: str):

def open_connection(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> None:
response_timeout: Union[float, int] = 3) -> None:
''' Opens WebSocket connection.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down
12 changes: 6 additions & 6 deletions livechat/utils/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ssl
import threading
from time import sleep
from typing import List, NoReturn
from typing import List, NoReturn, Union

from loguru import logger
from websocket import WebSocketApp, WebSocketConnectionClosedException
Expand All @@ -31,16 +31,16 @@ def __init__(self, *args, **kwargs):

def open(self,
origin: dict = None,
ping_timeout: float = 30,
ping_interval: float = 5,
ws_conn_timeout: float = 10,
ping_timeout: Union[float, int] = 3,
ping_interval: Union[float, int] = 5,
ws_conn_timeout: Union[float, int] = 10,
keep_alive: bool = True,
response_timeout: float = 3) -> NoReturn:
response_timeout: Union[float, int] = 3) -> NoReturn:
''' Opens websocket connection and keep running forever.
Args:
origin (dict): Specifies origin while creating websocket connection.
ping_timeout (int or float): timeout (in seconds) if the pong message is not received,
by default sets to 30 seconds.
by default sets to 3 seconds.
ping_interval (int or float): automatically sends "ping" command every specified period (in seconds).
If set to 0, no ping is sent periodically, by default sets to 5 seconds.
ws_conn_timeout (int or float): timeout (in seconds) to wait for WebSocket connection,
Expand Down

0 comments on commit d356f71

Please sign in to comment.