Skip to content

Commit ccb1d13

Browse files
committed
mi: add timeout parameter for datagram connection
1 parent a36bb59 commit ccb1d13

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

opensips/mi/datagram.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def __init__(self, **kwargs):
3434

3535
if "datagram_port" not in kwargs:
3636
raise ValueError("datagram_port is required for Datagram")
37-
37+
38+
self.timeout = kwargs.get("timeout", 1)
3839
self.ip = kwargs["datagram_ip"]
3940
self.port = int(kwargs["datagram_port"])
4041

@@ -44,7 +45,7 @@ def execute(self, method: str, params: dict):
4445
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
4546
try:
4647
udp_socket.sendto(jsoncmd.encode(), (self.ip, self.port))
47-
udp_socket.settimeout(5.0)
48+
udp_socket.settimeout(self.timeout)
4849
reply = udp_socket.recv(32768)
4950
except Exception as e:
5051
raise jsonrpc_helper.JSONRPCException(e)

0 commit comments

Comments
 (0)