Example #1
0
def continuation_callback(c_future, opaque_handle):
    try:
        py_future: "Future" = ffi.from_handle(opaque_handle)
        assert c_future == py_future.pimpl.handle
        if not py_future.stopped:
            py_future.then_cb(py_future, *py_future.then_args,
                              **py_future.then_kwargs)
    # pylint: disable=broad-except
    except Exception as exc:
        #
        # Uncaught exceptions stop reactor with error.
        # Setting the exception in the global Flux handle class will cause
        #  the handle to re-throw the exception after leaving the reactor:
        #
        flux_handle = py_future.get_flux()
        type(flux_handle).set_exception(exc)
        flux_handle.reactor_stop_error()

    finally:
        _THEN_HANDLES[py_future] -= 1
        if _THEN_HANDLES[py_future] <= 0:
            # allow future object to be garbage collected now that all
            # registered callbacks have completed
            py_future.cb_handle = None
            del _THEN_HANDLES[py_future]
Example #2
0
def timeout_handler_wrapper(unused1, unused2, revents, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    try:
        watcher.callback(watcher.flux_handle, watcher, revents, watcher.args)
    # pylint: disable=broad-except
    except Exception as exc:
        type(watcher.flux_handle).set_exception(exc)
        watcher.flux_handle.reactor_stop_error()
Example #3
0
def message_handler_wrapper(unused1, unused2, msg_handle, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    watcher.callback(
        watcher.flux_handle,
        watcher,
        Message(handle=msg_handle, destruct=False),
        watcher.args,
    )
Example #4
0
def message_handler_wrapper(unused1, unused2, msg_handle, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    watcher.callback(
        watcher.flux_handle,
        watcher,
        Message(handle=msg_handle, destruct=False),
        watcher.args,
    )
Example #5
0
def continuation_callback(c_future, opaque_handle):
    try:
        py_future = ffi.from_handle(opaque_handle)
        assert c_future == py_future.pimpl.handle
        py_future.then_cb(py_future, py_future.then_arg)
    finally:
        # allow future object to be garbage collected now that all
        # registered callbacks have completed
        py_future.cleanup_then()
Example #6
0
def signal_handler_wrapper(_unused1, _unused2, _unused3, opaque_handle):
    watcher = ffi.from_handle(opaque_handle)
    try:
        signal_int = raw.signal_watcher_get_signum(watcher.handle)
        watcher.callback(watcher.flux_handle, watcher, signal_int, watcher.args)
    # pylint: disable=broad-except
    except Exception as exc:
        type(watcher.flux_handle).set_exception(exc)
        watcher.flux_handle.reactor_stop_error()
Example #7
0
def continuation_callback(c_future, opaque_handle):
    try:
        py_future: "Future" = ffi.from_handle(opaque_handle)
        assert c_future == py_future.pimpl.handle
        py_future.then_cb(py_future, py_future.then_arg)
    finally:
        _THEN_HANDLES[py_future] -= 1
        if _THEN_HANDLES[py_future] <= 0:
            # allow future object to be garbage collected now that all
            # registered callbacks have completed
            py_future.cb_handle = None
            del _THEN_HANDLES[py_future]
Example #8
0
def message_handler_wrapper(unused1, unused2, msg_handle, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    try:
        watcher.callback(
            watcher.flux_handle,
            watcher,
            Message(handle=msg_handle),
            watcher.args,
        )
    # pylint: disable=broad-except
    except Exception as exc:
        type(watcher.flux_handle).set_exception(exc)
        watcher.flux_handle.reactor_stop_error()
Example #9
0
def signal_handler_wrapper(_unused1, _unused2, _unused3, opaque_handle):
    watcher = ffi.from_handle(opaque_handle)
    signal_int = raw.signal_watcher_get_signum(watcher.handle)
    watcher.callback(watcher.flux_handle, watcher, signal_int, watcher.args)
Example #10
0
def fd_handler_wrapper(unused1, unused2, revents, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    fd_int = raw.fd_watcher_get_fd(watcher.handle)
    watcher.callback(watcher.flux_handle, watcher, fd_int, revents,
                     watcher.args)
Example #11
0
def timeout_handler_wrapper(handle_trash, timer_watcher_s, revents,
                            opaque_handle):
    watcher = ffi.from_handle(opaque_handle)
    ret = watcher.cb(watcher.fh, watcher, revents, watcher.args)
Example #12
0
def message_handler_wrapper(handle_trash, m_watcher_t, msg_handle,
                            opaque_handle):
    watcher = ffi.from_handle(opaque_handle)
    ret = watcher.cb(watcher.fh, watcher,
                     flux.message.Message(handle=msg_handle,
                                          destruct=False), watcher.args)
Example #13
0
def timeout_handler_wrapper(unused1, unused2, revents, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    watcher.callback(watcher.flux_handle, watcher, revents, watcher.args)
Example #14
0
 def cb_then_wrapper(trash, arg):
     rpc_handle = ffi.from_handle(arg)
     callback(rpc_handle, rpc_handle.then_args)
Example #15
0
def message_handler_wrapper(handle_trash, m_watcher_t, msg_handle,
                            opaque_handle):
    watcher = ffi.from_handle(opaque_handle)
    ret = watcher.cb(watcher.fh, watcher,
                     flux.message.Message(handle=msg_handle,
                                          destruct=False), watcher.args)
Example #16
0
def timeout_handler_wrapper(handle_trash, watcher_s, revents,
                            opaque_handle):
    watcher = ffi.from_handle(opaque_handle)
    ret = watcher.cb(watcher.fh, watcher, revents, watcher.args)
Example #17
0
def fd_handler_wrapper(handle_trash, fd_watcher_s, revents,
                       opaque_handle):
    watcher = ffi.from_handle(opaque_handle)
    fd_int = raw.fd_watcher_get_fd(watcher.handle)
    ret = watcher.cb(watcher.fh, watcher, fd_int, revents, watcher.args)
Example #18
0
 def cb_then_wrapper(trash, arg):
     rpc_handle = ffi.from_handle(arg)
     callback(rpc_handle, rpc_handle.then_args)
Example #19
0
def signal_handler_wrapper(unused1, unused2, revents, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    signal_int = raw.signal_watcher_get_signum(watcher.handle)
    watcher.callback(watcher.flux_handle, watcher, signal_int, watcher.args)
Example #20
0
def timeout_handler_wrapper(unused1, unused2, revents, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    watcher.callback(watcher.flux_handle, watcher, revents, watcher.args)
Example #21
0
def fd_handler_wrapper(unused1, unused2, revents, opaque_handle):
    del unused1, unused2  # unused arguments
    watcher = ffi.from_handle(opaque_handle)
    fd_int = raw.fd_watcher_get_fd(watcher.handle)
    watcher.callback(watcher.flux_handle, watcher,
                     fd_int, revents, watcher.args)