Topics

How to bypass `core.CallCancelled: COM call cancelled` error?

André-Abush Clause
 

Hi all,

In one of my add-ons, I'd like to browse any virtual document in order to convert the document (including formatting) in Markdown. Unfortunately, I receive the following error after a few seconds with many documents (especially large):

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "NVDAObjects\__init__.pyc", line 733, in _get_recursiveDescendants
  File "NVDAObjects\__init__.pyc", line 733, in _get_recursiveDescendants
  File "NVDAObjects\__init__.pyc", line 733, in _get_recursiveDescendants
  [Previous line repeated 11 more times]
  File "NVDAObjects\__init__.pyc", line 731, in _get_recursiveDescendants
  File "baseObject.pyc", line 42, in __get__
  File "baseObject.pyc", line 145, in _getPropertyViaCache
  File "NVDAObjects\IAccessible\__init__.pyc", line 1050, in _get_children
  File "comtypesMonkeyPatches.pyc", line 34, in __call__
core.CallCancelled: COM call cancelled

You can easily reproduce this error like this as follows:

1. Go to https://www.nvaccess.org/ with Firefox/Chrome/Edge Canary.
2. Ensure that the review cursor is in the web page content.
3. Press NVDA+SHIFT+z
4. Paste and execute the following line:
for iObj, obj in enumerate(review.obj.rootNVDAObject.recursiveDescendants, 1): print(iObj, controlTypes.roleLabels[obj.role], obj.name, obj.value, obj.description, sep=" | ")

Result: after a few seconds, I receive the error mentioned above. Also, if I execute the loop several times, I note that the core stops the loop at different stages.

Any solution to avoid this?

Thanks and best regards,

André