mirror of
https://github.com/hemna/aprsd-telegram-plugin.git
synced 2024-11-21 23:55:18 -05:00
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.
This commit is contained in:
parent
a481862eea
commit
da0d448767
@ -1,6 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
from aprsd import messaging, objectstore, plugin, threads, trace
|
from aprsd import messaging, objectstore, plugin, threads, trace
|
||||||
from telegram.ext import Filters, MessageHandler, Updater
|
from telegram.ext import Filters, MessageHandler, Updater
|
||||||
@ -77,7 +78,7 @@ class TelegramChatPlugin(plugin.APRSDRegexCommandPluginBase):
|
|||||||
_help = [
|
_help = [
|
||||||
"telegram: Chat with a user on telegram Messenger.",
|
"telegram: Chat with a user on telegram Messenger.",
|
||||||
"telegram: username has to message you first."
|
"telegram: username has to message you first."
|
||||||
"tg: Send tg <shortcut/username> <message>",
|
"tg: Send tg <username> <message>",
|
||||||
]
|
]
|
||||||
return _help
|
return _help
|
||||||
|
|
||||||
@ -206,5 +207,7 @@ class TelegramThread(threads.APRSDThread):
|
|||||||
timeout=2,
|
timeout=2,
|
||||||
drop_pending_updates=True,
|
drop_pending_updates=True,
|
||||||
)
|
)
|
||||||
|
# So we don't eat 100% CPU
|
||||||
|
time.sleep(1)
|
||||||
# so we can continue looping
|
# so we can continue looping
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user