# Promises

class openpaperwork_core.promise.BasePromise(core, func=None, args=None, kwargs=None, parent=None, hide_caught_exceptions=False)
  catch(callback, *args, **kwargs)
  on_error(exc, hide_caught_exceptions=False)
  schedule(*args)
  then(callback, *args, **kwargs)
  wait()

class openpaperwork_core.promise.DelayPromise(core, delay_s)

  Promise adding delay between 2 other promises. Requires a plugin implementing the interface ‘mainloop’

  do(parent_r=None)

class openpaperwork_core.promise.Promise(core, func=None, args=None, kwargs=None, parent=None, hide_caught_exceptions=False)

  Executed in the main loop thread. Requires a plugin implementing the interface ‘mainloop’.

  do(parent_r=None)

class openpaperwork_core.promise.ThreadedPromise(core, func=None, args=None, kwargs=None, parent=None, hide_caught_exceptions=False)

  Promise for which the provided callback will be run in another thread, leaving the main loop thread free to do other things. Requires a plugin implementing the interface ‘mainloop’ and a plugin implementing the interface ‘thread’.

  IMPORTANT: This should ONLY be used for long-lasting tasks that cannot be split in small tasks (image processing, OCR, etc). The callback provided must be really careful regarding thread-safety.

  do(parent_r=None)