in pci_lib/pci_lib.py [0:0]
def defer_closes():
"""
Use with `with` to make pci_lib reuse fds and defer closing them until the
end of your with block.
Usage:
with pci_lib.defer_closes():
[... do some stuff with PCIDevice objects ...]
"""
try:
PCIConfigSpace.begin_defer()
yield
finally:
PCIConfigSpace.end_defer()