I\'m trying to convert some JavaScript code into Python, but JavaScript runs code asynchronously and has an easy event emitter-listener function to communicate between diffe