Intermittent failure add-in communicating with palette

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I have a fairly complex Add-in I am developing. The back end is Python that communicates with a GRBL controller over serial. The front end is an HTML palette. The backend sends status updates once a second. Things generally work well, but I occasionally get the error described by the screen shot. I'm developing the front end in Angular. This is the backend code handling the event fired from threads, I've marked the line that is failing:
# The event handler for messages sent from the back end actors
class ActorEventHandler(adsk.core.CustomEventHandler):
@trap_error
def notify(self, args):
msg = adsk.core.CustomEventArgs.cast(args).additionalInfo # this is failing
index = msg.find(":")
event_name = msg[: index]
data = msg[index + 1 :]
# Send information to the palette. This will trigger an event in the javascript
# within the html so that it can be handled.
palette = _ui.palettes.itemById(paletteId)
if palette: # palette not found if closed
try:
palette.sendInfoToHTML(event_name, data)
except:
# todo: log
pass
I'm using threading (an Actor implementation called Pykka.) This is how I'm firing the events from the threads:
_app.fireCustomEvent(paletteEventId, "{}:{}".format(event_name, data))
Can I get some idea of what is going on? As I said it generally works, occasionally fails. Unfortunately once if fails the first time I have to force quit F360 as the error pops up once a second with no way for me to stop the add-in. So it looks like some state changes and event firing will no longer work.
Thanks.
/Daryl