From da0d448767849a661b13ffc8f67efef9ac423e3f Mon Sep 17 00:00:00 2001 From: Hemna Date: Tue, 9 Nov 2021 11:19:19 -0500 Subject: [PATCH] Fixed a 100% CPU utilization issue. Have to put a sleep in the thread loop, or it will loop as fast as it can and consume 100% CPU. --- aprsd_telegram_plugin/telegram.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aprsd_telegram_plugin/telegram.py b/aprsd_telegram_plugin/telegram.py index 9ead0dc..a3d54c6 100644 --- a/aprsd_telegram_plugin/telegram.py +++ b/aprsd_telegram_plugin/telegram.py @@ -1,6 +1,7 @@ import datetime import logging import threading +import time from aprsd import messaging, objectstore, plugin, threads, trace from telegram.ext import Filters, MessageHandler, Updater @@ -77,7 +78,7 @@ class TelegramChatPlugin(plugin.APRSDRegexCommandPluginBase): _help = [ "telegram: Chat with a user on telegram Messenger.", "telegram: username has to message you first." - "tg: Send tg ", + "tg: Send tg ", ] return _help @@ -206,5 +207,7 @@ class TelegramThread(threads.APRSDThread): timeout=2, drop_pending_updates=True, ) + # So we don't eat 100% CPU + time.sleep(1) # so we can continue looping return True