當前位置: 首頁>>代碼示例>>Python>>正文


Python tornado.version_info方法代碼示例

本文整理匯總了Python中tornado.version_info方法的典型用法代碼示例。如果您正苦於以下問題:Python tornado.version_info方法的具體用法?Python tornado.version_info怎麽用?Python tornado.version_info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tornado的用法示例。


在下文中一共展示了tornado.version_info方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import tornado [as 別名]
# 或者: from tornado import version_info [as 別名]
def __init__(self, handlers=None,
                 default_host="",
                 transforms=None,
                 wsgi=False,
                 middlewares=None,
                 **settings):

        super(Application, self).__init__(
            handlers=handlers,
            default_host=default_host,
            transforms=transforms,
            wsgi=wsgi, **settings)

        self.middleware_fac = Manager()
        if middlewares:
            self.middleware_fac.register_all(middlewares)
            self.middleware_fac.run_init(self)

        if version_info[0] > 3:
            this = self

            class HttpRequest(httputil.HTTPServerRequest):
                def __init__(self, *args, **kwargs):
                    super(HttpRequest, self).__init__(*args, **kwargs)
                    this.middleware_fac.set_request(self)
                    try:
                        this.middleware_fac.run_call(self)
                    except Exception:
                        SysLogger.trace_logger.error(traceback.format_exc())

            httputil.HTTPServerRequest = HttpRequest 
開發者ID:mqingyn,項目名稱:torngas,代碼行數:33,代碼來源:application.py

示例2: __call__

# 需要導入模塊: import tornado [as 別名]
# 或者: from tornado import version_info [as 別名]
def __call__(self, request):
        if version_info[0] < 4:
            try:
                self.middleware_fac.set_request(request)
                self.middleware_fac.run_call(request)
                return web.Application.__call__(self, request)

            except Exception, e:
                SysLogger.trace_logger.error(e)
                raise 
開發者ID:mqingyn,項目名稱:torngas,代碼行數:12,代碼來源:application.py

示例3: __init__

# 需要導入模塊: import tornado [as 別名]
# 或者: from tornado import version_info [as 別名]
def __init__(self, callback, schedule, io_loop=None, is_utc=False):
        """ CrontabCallback initializer

        :type callback: func
        :param callback: target schedule function
        :type schedule: str
        :param schedule: crotab expression
        :type io_loop: tornado.ioloop.IOLoop
        :param io_loop: tornado IOLoop
        :type is_utc: bool
        :param is_utc: schedule timezone is UTC. (True:UTC, False:Local Timezone)
        """

        # If Timezone is not supported and `is_utc` is set to `True`,
        # a warning is output and `is_utc` is ignored.
        if not IS_TZ_SUPPORTED and is_utc:
            warnings.warn(UNSUPPORTED_TZ_MESSAGE)
            is_utc = False

        self.__crontab = CronTab(schedule)
        self.__is_utc = is_utc

        arguments = dict(
            callback=callback, callback_time=self._calc_callbacktime())

        if tornado_version_info >= (5,):
            if io_loop is not None:
                warnings.warn(UNSUPPORTED_IOLOOP_MESSAGE)
        else:
            arguments.update(io_loop=io_loop)

        super(CronTabCallback, self).__init__(**arguments)

        self.pid = os.getpid()

        if os.name == "nt":
            self.user = os.environ.get("USERNAME")
        else:
            import pwd
            self.user = pwd.getpwuid(os.geteuid()).pw_name 
開發者ID:gaujin,項目名稱:tornado-crontab,代碼行數:42,代碼來源:_crontab.py

示例4: pingable_ws_connect

# 需要導入模塊: import tornado [as 別名]
# 或者: from tornado import version_info [as 別名]
def pingable_ws_connect(request=None,on_message_callback=None,
                        on_ping_callback=None, subprotocols=None):
    """
    A variation on websocket_connect that returns a PingableWSClientConnection
    with on_ping_callback.
    """
    # Copy and convert the headers dict/object (see comments in
    # AsyncHTTPClient.fetch)
    request.headers = httputil.HTTPHeaders(request.headers)
    request = httpclient._RequestProxy(
        request, httpclient.HTTPRequest._DEFAULTS)

    # for tornado 4.5.x compatibility
    if version_info[0] == 4:
        conn = PingableWSClientConnection(io_loop=ioloop.IOLoop.current(),
            compression_options={},
            request=request,
            on_message_callback=on_message_callback,
            on_ping_callback=on_ping_callback)
    else:
        conn = PingableWSClientConnection(request=request,
            compression_options={},
            on_message_callback=on_message_callback,
            on_ping_callback=on_ping_callback,
            max_message_size=getattr(websocket, '_default_max_message_size', 10 * 1024 * 1024),
            subprotocols=subprotocols)

    return conn.connect_future

# from https://stackoverflow.com/questions/38663666/how-can-i-serve-a-http-page-and-a-websocket-on-the-same-url-in-tornado 
開發者ID:jupyterhub,項目名稱:jupyter-server-proxy,代碼行數:32,代碼來源:websocket.py

示例5: _newer_or_equal_

# 需要導入模塊: import tornado [as 別名]
# 或者: from tornado import version_info [as 別名]
def _newer_or_equal_(v):
    for i in six.moves.xrange(min(len(v), len(version_info))):
        expected, tnd = v[i], version_info[i]
        if tnd > expected:
            return True
        elif tnd == expected:
            continue
        else:
            return False
    return True 
開發者ID:toastdriven,項目名稱:restless,代碼行數:12,代碼來源:test_tnd.py

示例6: _equal_

# 需要導入模塊: import tornado [as 別名]
# 或者: from tornado import version_info [as 別名]
def _equal_(v):
    for i in six.moves.xrange(min(len(v), len(version_info))):
        if v[i] != version_info[i]:
            return False
    return True 
開發者ID:toastdriven,項目名稱:restless,代碼行數:7,代碼來源:test_tnd.py


注:本文中的tornado.version_info方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。