simplify external ip logic

This commit is contained in:
Victor Shyba 2020-02-20 12:12:30 -03:00
parent 050b67c9d6
commit 5394f1763c
2 changed files with 2 additions and 4 deletions

View file

@ -127,16 +127,14 @@ class AnalyticsManager:
async def start(self):
if self.task is None:
self.external_ip = await utils.get_external_ip() if self.enabled else None
self.task = asyncio.create_task(self.run())
async def run(self):
while True:
if self.enabled:
self.external_ip = await utils.get_external_ip()
await self._send_heartbeat()
await asyncio.sleep(1800)
if self.enabled:
self.external_ip = await utils.get_external_ip()
def stop(self):
if self.task is not None and not self.task.done():

View file

@ -51,7 +51,7 @@ class HTTPSLogglyHandler(logging.Handler):
@property
def enabled(self):
return self._toggle is None or (self._toggle and self._toggle())
return self._toggle and self._toggle()
@staticmethod
def get_full_message(record):