As I have several projects using the same code basis I wanted to optimize a bit my plugins in order to avoid having to maintain the same code in different places.
Hence I designed my plugins as Classes and put some inheritance between projects plugins and core plugins.
When I run my tests, everything goes fine.
But when I start my project daemon it crashes on first event because of a failed callback. It shows an IndexError and I guess it is because of the empty stack, but I can’t find a way to handle this (I modified the code so it would try the usual way first, then show an alternative message):
INFO:engine:Loading plugin at /app/package/int/shotgun_event_plugins/current/projects/toto/plugins/actorbundle.py INFO:engine:Loading plugin at /app/package/int/shotgun_event_plugins/current/projects/toto/plugins/asset.py INFO:engine:Loading plugin at /app/package/int/shotgun_event_plugins/current/common/plugins/review.py INFO:engine:Loading plugin at /app/package/int/shotgun_event_plugins/current/common/plugins/timelog.py INFO:engine:Loading plugin at /app/package/int/shotgun_event_plugins/current/common/plugins/episode.py INFO:engine:Loading plugin at /app/package/int/shotgun_event_plugins/current/projects/toto/plugins/task.py INFO:engine:Treating event 13835317 CRITICAL:plugin.task.manage_task:An error occured processing an event. Traceback (most recent call last): File "/app/package/int/shotgun_events/2.0.4/shotgunEvents/src/shotgunEventDaemon.py", line 1488, in process self._logger.critical(msg, traceback.format_exc(), pprint.pformat(stack.f_locals)) IndexError: list index out of range Local variables at outer most frame in plugin: 'no local variables' INFO:timing:event_id=13835317 created_at=2019-07-03T13:10:18+02:00 callback=task.manage_task start=2019-12-11T11:35:34.495531+01:00 end=2019-12-11T11:35:36.279610+01:00 duration=00:00:00:01.784079 error=True delay=160:23:25:16.495531
What puzzles me is that the timing log seems to recognize the callback !
So first question would be: is it ok to use plugins as classes?
Then: are there special tricks to do this?