Use `try/except KeyError` in place of `if in dict/else`
This commit is contained in:
parent
716f7617c4
commit
f389c43e43
|
@ -697,13 +697,13 @@ class NetworkLoadSegment(KwThreadedSegment):
|
|||
total = activity
|
||||
interface = name
|
||||
|
||||
if interface in self.interfaces:
|
||||
try:
|
||||
idata = self.interfaces[interface]
|
||||
try:
|
||||
idata['prev'] = idata['last']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
except KeyError:
|
||||
idata = {}
|
||||
if self.run_once:
|
||||
idata['prev'] = (monotonic(), _get_bytes(interface))
|
||||
|
|
Loading…
Reference in New Issue