Your callback will have access to myPayload due to its presence in the local variable namespace when the def executes. This is called closure. Worth learning to use. Another option is applying python’s partial function to yield a function that carries your payload.
but is there any risk of memory leak with this class if the function promise.then(…) is called every x seconds ? I don’t know when CallBackWithPayload instances will be garbage collected…?
Is it throwing an error? In a few tag related scripting functions we're doing too strict of a check for callable functions, so httpClient might be doing something similar. partial would be the recommended way forward...