Skip to content

Commit

Permalink
Fix for request connector CPU load #1626, thanks @lindnma
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Jan 7, 2025
1 parent 2d0e63f commit 571dceb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions thingsboard_gateway/connectors/request/request_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ def __init__(self, gateway, config, connector_type):

def run(self):
while not self.__stopped:
request_sent = False
if self.__requests_in_progress:
for request in self.__requests_in_progress:
if time() >= request["next_time"]:
thread = Thread(target=self.__send_request, args=(request, self.__convert_queue, self._log),
for req in self.__requests_in_progress:
if time() >= req["next_time"]:
thread = Thread(target=self.__send_request, args=(req, self.__convert_queue, self._log),
daemon=True,
name="Request to endpoint \'%s\' Thread" % (request["config"].get("url")))
name="Request to endpoint \'%s\' Thread" % (req["config"].get("url")))
thread.start()
else:
request_sent = True
if not request_sent:
sleep(.2)
self.__process_data()

Expand Down

0 comments on commit 571dceb

Please sign in to comment.