def METHOD_NAME(priority, cancellable, callback):
    def callback_main(cancellable, callback, result):
        if not cancellable.is_cancelled():
            callback(result)
        return False
    def callback_thread(future):
        global _prio_mapping
        result = future.result()
        if not cancellable.is_cancelled():
            glib_priority = _prio_mapping[priority]
            GLib.idle_add(callback_main, cancellable, callback, result,
                          priority=glib_priority)
    return callback_thread