MCederholm

Python add-ins: Event listeners can cause problems

Discussion created by MCederholm on Dec 28, 2012
I would not normally start an edit session programmatically while listening for an onCreateFeature event, but this problem was brought to my attention and I was able to duplicate it.  If I have a Python add-in consisting of an extension which listens for the onCreateFeature event, and a button which calls the Editor (through comtypes) to start an edit session, an Access Violation error will result when the button attempts to start the edit session.  If the extension is deactivated, the error doesn't occur.

If I start the edit session from a separate Python instance while the extension is active, the error doesn't occur either.  This leads me to believe that whatever mechanism is used to listen for Editor events is causing some sort of contention in the Python engine when simultaneously manipulating the Editor object.  What do you think?

Outcomes