AWS Thinkbox Discussion Forums

adding 2+ events to the same callback

I get this error:

2016-01-07 15:14:15: An error occurred in the “OnJobFinished” function in events plugin ‘Scanline’: An error occurred in function “OnJobFinished” the event plugin script file “\inferno2\deadline\test_repository7\events\Scanline\Scanline.py”: OnJobFinishedCallback has more than one callback registered (Deadline.Events.DeadlineEventPluginException)
2016-01-07 15:14:15: at Deadline.Events.DeadlineEventPlugin.a(String A_0, Exception A_1)
2016-01-07 15:14:15: at Deadline.Events.DeadlineEventPlugin.OnJobFinished(Job job, String[] auxiliaryFilenames)
2016-01-07 15:14:15: at Deadline.Events.DeadlineEventManager.OnJobsFinished(Job[] jobs, DataController dataController)

Is adding more than one event for the same callback not allowed?

Would you be able to provide the .py file for the event plugin that triggers this exception? That looks like an initialization problem. You can definitely have multiple events using the same callback.

I had something like this:

class ScanlineEventListener(DeadlineEventListener):
    def __init__(self):
        ClientUtils.LogText("ScanlineEventListener _init__ called, wiping PYTHONPATH from deadlineslave's embedded python")
        ClientUtils.LogText("Enabling render stat mail")
        self.CleanEnvironmentVariables()
        self.OnJobFinishedCallback += self.OnJobFinished
        
        self.OnJobFailedCallback += self.CalcSize
        self.OnJobFinishedCallback += self.CalcSize
        self.OnJobDeletedCallback += self.CalcSize
        self.OnJobSuspendedCallback += self.CalcSize        

    def Cleanup(self):
        del self.OnJobFinishedCallback
        
        del self.OnJobFailedCallback
        del self.OnJobDeletedCallback
        del self.OnJobSuspendedCallback        
        

Note the OnJobFinishedCallback having 2 functions added

Having one callback assigned to multiple functions within a script is not supported. Your code can be easily refactored to get the behavior you’re intending by calling one function from the other :slight_smile:

Yeah that’s what i ended up doing.
Is there a reason for this limitation? While working with delegate and event functions, its quite common to chain more then one function into same event (hence the += when adding the function call)

There is a limitation in Python.NET that prevents us from having multiple events assigned to the same callback. For that reason we do a one-to-one mapping between listeners and callback functions.

Odd… i recall using python.net like that, but maybe i’m mixing it up with pure c#… its been years since i last dealt with that :slight_smile:

cheers
laszlo

Privacy | Site terms | Cookie preferences