How to use the tornado.gen.Return function in tornado

To help you get started, we’ve selected a few tornado examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UniPiTechnology / evok / tornadorpc_evok / base.py View on Github external
or keyword arguments, not mixed.
        """
        try:
            assert(not hasattr(RequestHandler, method_name))
            print method_name
            method = self
            method_list = dir(method)
            method_list.sort()
            attr_tree = method_name.split('.')
            for attr_name in attr_tree:
                method = self._RPC_.check_method(attr_name, method)
            assert(callable(method))
            assert(not method_name.startswith('_'))
            assert(not getattr(method, 'private', False))
        except Exception,e :
            raise gen.Return(self._RPC_.faults.method_not_found())

        args = []
        kwargs = {}
        try:
            if isinstance(params, dict):
                # The parameters are keyword-based
                kwargs = params
            elif type(params) in (list, tuple):
                # The parameters are positional
                args = params
            else:
                # Bad argument formatting?
                raise Exception()
            # Validating call arguments
            final_kwargs, extra_args = getcallargs(method, *args, **kwargs)
        except Exception:
github urbn / Caesium / caesium / document.py View on Github external
:rtype: list

        """

        cursor = self.collection.find(query)

        if orderby:
            cursor.sort(orderby, order_by_direction)

        cursor.skip(page*limit).limit(limit)

        results = []
        while (yield cursor.fetch_next):
            results.append(self._obj_cursor_to_dictionary(cursor.next_object()))

        raise Return(results)
github aiidateam / aiida-core / aiida / engine / utils.py View on Github external
def wrapper(*args, **kwargs):
        raise tornado.gen.Return(fct(*args, **kwargs))
github Nextdoor / kingpin / kingpin / actors / rightscale / server_template.py View on Github external
def _compare_operational_bindings(self):
        raise gen.Return(self._compare_bindings(
            self.desired_operational_bindings,
            self.operational_bindings))
github googlecolab / jupyter_http_over_ws / jupyter_http_over_ws / handlers.py View on Github external
def _get_proxied_ws(self):
    if not self._proxied_ws_future:
      raise gen.Return()

    try:
      client = yield self._proxied_ws_future
    except Exception as e:  # pylint:disable=broad-except
      self._on_unhandled_exception(e)
    else:
      raise gen.Return(client)
github AppScale / appscale / AppDB / appscale / datastore / scripts / ua_server.py View on Github external
if secret != super_secret:
    raise gen.Return("Error: bad secret")

  if pg_connection_wrapper:
    with pg_connection_wrapper.get_connection() as pg_connection:
      with pg_connection.cursor() as pg_cursor:
        pg_cursor.execute(
          'SELECT enabled FROM "{table}" '
          'WHERE email = %(user)s'
          .format(table=table_name),
          vars={'user': user}
        )
        result = pg_cursor.fetchone()

    if not result:
      raise gen.Return("false")
    raise gen.Return(str(result[0]).lower())

  try:
    result = yield db.get_entity(USER_TABLE, user, ['enabled'])
  except AppScaleDBConnectionError as db_error:
    raise gen.Return('Error: {}'.format(db_error))

  if result[0] not in ERROR_CODES or len(result) == 1:
    raise gen.Return("false")
  raise gen.Return(result[1])
github FZambia / centrifuge / src / centrifuge / state / redis.py View on Github external
def is_deactivated(self, project_id, user_id):
        key = self.get_deactivated_key(project_id, user_id)
        try:
            data = yield Task(self.client.get, key)
        except StreamClosedError as e:
            raise Return((None, e))
        else:
            result = False
            if data:
                result = True
            raise Return((result, None))
github TeamHG-Memex / arachnado / arachnado / sitechecker.py View on Github external
def update(self, doc):
        doc = replace_dots(doc)
        doc_copy = deepcopy(doc)
        doc_copy.pop('_id')
        result = yield self.col.update({
            '_id': ObjectId(doc['_id'])
        }, {
            '$set': doc_copy
        })
        self.signals.send_catch_log(site_updated, site=doc)
        raise Return(result)
github alumae / kaldi-gstreamer-server / kaldigstserver / worker.py View on Github external
else:
                timeout=0.0
            try:
                with (yield self.post_processor_lock.acquire(timeout)):
                    result = []
                    for text in texts:
                        self.post_processor.stdin.write("%s\n" % text.encode("utf-8"))
                        self.post_processor.stdin.flush()
                        logging.debug("%s: Starting postprocessing: %s"  % (self.request_id, text))
                        text = yield self.post_processor.stdout.read_until('\n')
                        text = text.decode("utf-8")
                        logging.debug("%s: Postprocessing returned: %s"  % (self.request_id, text))
                        text = text.strip()
                        text = text.replace("\\n", "\n")
                        result.append(text)
                    raise tornado.gen.Return(result)
            except tornado.gen.TimeoutError:
                logging.debug("%s: Skipping postprocessing since post-processor already in use"  % (self.request_id))
                raise tornado.gen.Return(None)
        else:
            raise tornado.gen.Return(texts)
github AppScale / appscale / AppDB / appscale / datastore / fdb / data.py View on Github external
def _data_ns(self, tr, project_id, namespace):
    directory = yield self._directory_cache.get(
      tr, DataNamespace.directory_path(project_id, namespace))
    raise gen.Return(DataNamespace(directory))