Menu

#746 pywintypes.com_error when querying WMI

v1.0 (example)
closed-invalid
nobody
None
5
2017-03-02
2017-03-01
No

Hello,
I'm trying to get IIS site state using WMI, and getting errors from pywin32.
The errors occur not every time I call the script. In general it works well. But sometimes I get the following:

Traceback (most recent call last):
File "C:\zabbix_agents\py_scripts\zabbix_item_IIS_site_state.py", line 14, in <module>
sites = WMI(namespace=WMI_IIS_NAMESPACE).query("SELECT * FROM Site WHERE Name = '{}'".format(args.site))
File "C:\Program Files\Python35\lib\site-packages\wmi.py", line 1009, in query
return [ _wmi_object (obj, instance_of, fields) for obj in self._raw_query(wql) ]
File "C:\Program Files\Python35\lib\site-packages\wmi.py", line 1009, in <listcomp>
return [ _wmi_object (obj, instance_of, fields) for obj in self._raw_query(wql) ]
File "C:\Program Files\Python35\lib\site-packages\win32com\client\dynamic.py", line 252, in getitem
return self.get_good_object(self.enum.getitem(index))
File "C:\Program Files\Python35\lib\site-packages\win32com\client\util.py", line 37, in getitem
return self.GetIndex(index)
File "C:\Program Files\Python35\lib\site-packages\win32com\client\util.py", line 53, in
GetIndex
result = self.oleobj.Next(1)
pywintypes.com_error: (-2147417851, 'The server threw an exception.', None, None)

or:

Traceback (most recent call last):
File "C:\zabbix_agents\py_scripts\zabbix_item_IIS_site_state.py", line 14, in <module>
sites = WMI(namespace=WMI_IIS_NAMESPACE).query("SELECT * FROM Site WHERE Name = '{}'".format(args.site))
File "C:\Program Files\Python35\lib\site-packages\wmi.py", line 1009, in query
return [ _wmi_object (obj, instance_of, fields) for obj in self._raw_query(wql) ]
File "C:\Program Files\Python35\lib\site-packages\wmi.py", line 1009, in <listcomp>
return [ _wmi_object (obj, instance_of, fields) for obj in self._raw_query(wql) ]
File "C:\Program Files\Python35\lib\site-packages\win32com\client\dynamic.py", line 252, in getitem
return self.get_good_object(self.enum.getitem(index))
File "C:\Program Files\Python35\lib\site-packages\win32com\client\util.py", line 37, in getitem
return self.GetIndex(index)
File "C:\Program Files\Python35\lib\site-packages\win32com\client\util.py", line 53, in
GetIndex
result = self.oleobj.Next(1)
pywintypes.com_error: (-2147024882, 'Not enough storage is available to complete this operation.', None, None)

My Python ver is 3.5 x64. Pywin32 is Build 220.
Much appreciate any help on the issue.

Discussion

  • Mark Hammond

    Mark Hammond - 2017-03-02
    • status: open --> closed-invalid
     
  • Mark Hammond

    Mark Hammond - 2017-03-02

    There's no reson to believe this is a pywin32 issue, but rather a more general issue with WMI. You might like to resend your question to the python-win32 mailing list. You need to be subscribed to the list before you can post to it - see http://mail.python.org/mailman/listinfo/python-win32 for subscription options.