Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

chore: InfluxDBClient.close should also close udp socket #906

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def __init__(self,

if use_udp:
self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
else:
self.udp_socket = None

if not path:
self.__path = ''
Expand Down Expand Up @@ -1199,9 +1201,11 @@ def send_packet(self, packet, protocol='json', time_precision=None):
self.udp_socket.sendto(data, (self._host, self._udp_port))

def close(self):
"""Close http session."""
"""Close any network connections for this client."""
if isinstance(self._session, requests.Session):
self._session.close()
if self.udp_socket is not None:
self.udp_socket.close()


def _parse_dsn(dsn):
Expand Down