Python google.appengine.runtime.apiproxy_errors.InterruptedError() Examples

The following are code examples for showing how to use google.appengine.runtime.apiproxy_errors.InterruptedError(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: python-compat-runtime   Author: GoogleCloudPlatform   File:    Apache License 2.0 6 votes vote down vote up
def __internal_callback(self):
    """This is the callback set on the low-level RPC object.

    It sets a flag on the current object indicating that the high-level
    callback should now be called.  If interrupts are enabled, it also
    interrupts the current wait_any() call by raising an exception.
    self.__must_call_user_callback = True
    self.__rpc.callback = None
    if self.__class__.__local.may_interrupt_wait and not self.__rpc.exception:

      raise apiproxy_errors.InterruptedError(None, self.__rpc) 
Example 2
Project: python-compat-runtime   Author: GoogleCloudPlatform   File:    Apache License 2.0 6 votes vote down vote up
def _WaitImpl(self):
    """Waits on the API call associated with this RPC. The callback,
    if provided, will be executed before Wait() returns. If this RPC
    is already complete, or if the RPC was never started, this
    function will return immediately.

      InterruptedError if a callback throws an uncaught exception.
      rpc_completed = _apphosting_runtime___python__apiproxy.Wait(self)
    except (runtime.DeadlineExceededError, apiproxy_errors.InterruptedError):
      exc_class, exc, tb = sys.exc_info()
      if (isinstance(exc, SystemError) and
          exc.args[0] == 'uncaught RPC exception'):
      rpc = None
      if hasattr(exc, "_appengine_apiproxy_rpc"):
        rpc = exc._appengine_apiproxy_rpc

      new_exc = apiproxy_errors.InterruptedError(exc, rpc)
      raise new_exc.__class__, new_exc, tb
    return True 
Example 3
Project: python-compat-runtime   Author: GoogleCloudPlatform   File:    Apache License 2.0 4 votes vote down vote up
def wait_any(cls, rpcs):
    """Wait until an RPC is finished.

      rpcs: Iterable collection of UserRPC instances.

      A UserRPC instance, indicating the first RPC among the given
      RPCs that finished; or None, indicating that either an RPC not
      among the given RPCs finished in the mean time, or the iterable
      is empty.


    (1) Repeatedly calling wait_any() with the same arguments will not
        make progress; it will keep returning the same RPC (the one
        that finished first).  The callback, however, will only be
        called the first time the RPC finishes (which may be here or
        in the wait() method).

    (2) It may return before any of the given RPCs finishes, if
        another pending RPC exists that is not included in the rpcs
        argument.  In this case the other RPC's callback will *not*
        be called.  The motivation for this feature is that wait_any()
        may be used as a low-level building block for a variety of
        high-level constructs, some of which prefer to block for the
        minimal amount of time without busy-waiting.
    assert iter(rpcs) is not rpcs, 'rpcs must be a collection, not an iterator'
    finished, running = cls.__check_one(rpcs)
    if finished is not None:
      return finished
    if running is None:
      return None
      cls.__local.may_interrupt_wait = True
      except apiproxy_errors.InterruptedError, err:

        err.rpc._exception = None
        err.rpc._traceback = None
      cls.__local.may_interrupt_wait = False
    finished, runnning = cls.__check_one(rpcs)
    return finished