Use contextlib.suppress where possible (#48189)
This commit is contained in:
parent
9656f260a4
commit
6932cf9534
86 changed files with 238 additions and 398 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue