code: def _api_call(function):
      
      @wraps(function)
      def wrapper(*args, **kwargs):
          try:
              if not _webview_ready.wait(15):
                  raise Exception('Main window failed to start')
              return function(*args, **kwargs)
          except NameError:
              raise Exception('Create a web view window first, before invoking this function')
          except KeyError as e:
              try:
                  uid = kwargs['uid']
              except KeyError:
                  # uid not passed as a keyword arg, assumes it to be last in the arg list
                  uid = args[-1]
              raise Exception('Cannot call function: No webview exists with uid: {}'.format(uid))
      return wrapper
docs: Decorator to call a pywebview API, checking for _webview_ready and raisings
      appropriate Exceptions on failure.