[New-bugs-announce] [issue14597] Cannot unload dll in ctypes until script exits

Pat Lynch report at bugs.python.org
Mon Apr 16 15:09:33 CEST 2012

New submission from Pat Lynch <plynch76 at gmail.com>:

If I load a dll in ctypes, then delete that loaded DLL instance, the DLL is not unloaded until the script finishes and exits.

I'm trying to write some unit tests in python to exercise that DLL where each test case loads a DLL, does some work, then unloads the DLL.  Unfortunately the DLL only gets unloaded when the unit tests finish.

I've tried forcing the garbage collector to run to get the DLL to unload.  It did nothing...

# load the DLL
parser_dll = CDLL(dllpath)

# do some work here

# 'unload' the dll (or as close as I can get it to it)
if (parser_dll):
    del parser_dll

components: ctypes
messages: 158433
nosy: plynch76
priority: normal
severity: normal
status: open
title: Cannot unload dll in ctypes until script exits
type: enhancement
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list