heikoengel / pyPCIe

Simple Python Module to access PCIe Endpoint BARs
MIT License
16 stars 4 forks source link

fd in Bar() is not closed #1

Closed micpez closed 1 year ago

micpez commented 1 year ago

When Bar() is deleted, mmap is closed but fd is left open:

def __del__(self):
    if self.__map is not None:
        self.__map.close()

I happend to loop and create several times Bar() for the same pci sbdf and I got: OSError: [Errno 24] Too many open files

Saving fd and closing it solved the issue:

def __del__(self):
    if self.__map is not None:
        self.__map.close()
    os.close(self._fd)
heikoengel commented 1 year ago

Thanks!

micpez commented 1 year ago

You're welcome! Any plans to push a new version to pypy appreciated.

heikoengel commented 1 year ago

should be available on pypi now as version 0.1.1