Use contextlib.suppress where possible (#48189)

This commit is contained in:
Franck Nijhof 2021-03-23 14:36:43 +01:00 committed by GitHub
parent 9656f260a4
commit 6932cf9534
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 238 additions and 398 deletions

View file

@ -1,4 +1,5 @@
"""Support for Zabbix."""
from contextlib import suppress
import json
import logging
import math
@ -202,7 +203,7 @@ class ZabbixThread(threading.Thread):
dropped = 0
try:
with suppress(queue.Empty):
while len(metrics) < BATCH_BUFFER_SIZE and not self.shutdown:
timeout = None if count == 0 else BATCH_TIMEOUT
item = self.queue.get(timeout=timeout)
@ -223,9 +224,6 @@ class ZabbixThread(threading.Thread):
else:
dropped += 1
except queue.Empty:
pass
if dropped:
_LOGGER.warning("Catching up, dropped %d old events", dropped)