Catch exceptions in various locations to fix small issues reported by Sentry.

This commit is contained in:
grossmj committed 2018-09-06 09:49:12 +02:00
1 parent 341e2e2e3a
commit 4021a13651
8 files changed
+63 -40

No files matched your search

+2 -4
View File
@@ -197,11 +197,9 @@ class AsyncioTelnetServer:
yield from self._write_intro(network_writer, echo=self._echo, binary=self._binary, naws=self._naws)
yield from connection.connected()
yield from self._process(network_reader, network_writer, connection)
except ConnectionResetError:
except ConnectionError:
with (yield from self._lock):
network_writer.close()
if self._reader_process == network_reader:
self._reader_process = None
# Cancel current read from this reader
@@ -217,7 +215,7 @@ class AsyncioTelnetServer:
try:
writer.write_eof()
yield from writer.drain()
except ConnectionResetError:
except ConnectionError:
continue
@asyncio.coroutine
+10 -2
View File
@@ -43,8 +43,16 @@ class PingStats:
cur_time > cls._last_measurement + 1.9:
cls._last_measurement = cur_time
# Non blocking call to get cpu usage. First call will return 0
cls._last_cpu_percent = psutil.cpu_percent(interval=None)
cls._last_mem_percent = psutil.virtual_memory().percent
try:
cls._last_cpu_percent = psutil.cpu_percent(interval=None)
cls._last_mem_percent = psutil.virtual_memory().percent
except RuntimeError:
# ignore the following error:
# RuntimeError: host_statistics(HOST_CPU_LOAD_INFO) syscall failed: (ipc/send) invalid reply port
pass
except PermissionError:
# [Errno 13] Permission denied: '/proc/stat'
pass
stats["cpu_usage_percent"] = cls._last_cpu_percent
stats["memory_usage_percent"] = cls._last_mem_percent
return stats