[python-win32] Opening and enumerating resource many times

Gustavo Tabares gustavotabares at gmail.com
Thu Jan 29 19:09:17 CET 2009


Hi all,

I'm having a problem when opening and enumerating a network resource
many times.  For example:

i = 0

while i < 10000:
       handle =
win32wnet.WNetOpenEnum(win32netcon.RESOURCE_CONNECTED,
win32netcon.RESOURCETYPE_ANY, 0, None)
       partial_nr_list = win32wnet.WNetEnumResource(handle)
       while partial_nr_list:
           partial_nr_list = win32wnet.WNetEnumResource(handle)
       win32wnet.WNetCloseEnum(handle)

       i += 1


This eventually fails with:

Traceback (most recent call last):
 File "C:\qtest.py", line 17, in <module>
   partial_nr_list = win32wnet.WNetEnumResource(handle)
MemoryError: VirtualAlloc error in WNetEnumResource


I took a look at the source for win32wnet.WNetEnumResource and it
seems to be doing the correct thing in terms of memory. My application
isn't doing the above exactly, however it does open/enumerate many
times. Any ideas on what may be going on?


Thanks,
Gustavo


More information about the python-win32 mailing list