I am designing a python API which takes some parameters. My primary requirement for this API is that calling module should be notified in case of some event X and it should also wait for the execution to complete.
I have already thought of passing a callback function to get executed on event X but I cannot do that since that method is tightly coupled to the callee.
This is what I want to achieve:
test = API().run()
On Event X, control should come back to test and then I wait again on previous API.run to complete.
So something like this
while (waiting on run to complete) or (X does not happens):
doX()
Here I somehow want API to communicate to me X has happened