After a lot of work into figuring this one out, it turned out that the leak was happening in a different python package, “openslide”, which is necessary for handling the digital pathology whole slides. Sorry for the trouble and thanks for your help.