Skip to content

Commit

Permalink
discovery: empty list of last discovered nodes using ND
Browse files Browse the repository at this point in the history
When a non-deep discovery is launched, all discovered nodes are added to a
list. But this list is never emptied that is clearly a memory leak.

This commit clears this list before starting a new discovery process and once
the discovery of a list of devices finishes.

#172

Signed-off-by: Tatiana Leon <tatiana.leon@digi.com>
  • Loading branch information
tatianaleon committed May 14, 2020
1 parent ad70f92 commit 9688688
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion digi/xbee/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7765,7 +7765,9 @@ def discover_devices(self, device_id_list):
self.start_discovery_process()
while self.is_discovery_running():
time.sleep(0.1)
return list(filter(lambda x: x.get_node_id() in device_id_list, self.__last_search_dev_list))
discovered_devices = list(filter(lambda x: x.get_node_id() in device_id_list, self.__last_search_dev_list))
self.__last_search_dev_list.clear()
return discovered_devices

def is_discovery_running(self):
"""
Expand Down Expand Up @@ -8815,6 +8817,7 @@ def __discover_devices_and_notify_callbacks(self, discover_network=False):
with a single 'ND'.
"""
self._stop_event.clear()
self.__last_search_dev_list.clear()
self.__discovering = True
self.__discover_result = None

Expand Down

0 comments on commit 9688688

Please sign in to comment.