code: def wait(self, promise, timeout=None):
      e = Event()
  
      def on_resolve_or_reject(_):
          e.set()
  
      promise._then(on_resolve_or_reject, on_resolve_or_reject)
      waited = e.wait(timeout)
      if not waited:
          raise Exception("Timeout")
  
imports: from threading import Thread, Event
label_desc: Use image node_id 2 for calling the ThreadScheduler obj's underlying member method code with example usage: obj.wait(promise, timeout) without return types