Python tornado.version_info() Examples
The following are 6
code examples of tornado.version_info().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tornado
, or try the search function
.
Example #1
Source File: application.py From torngas with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #2
Source File: application.py From torngas with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #3
Source File: _crontab.py From tornado-crontab with MIT License | 5 votes |
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
Example #4
Source File: websocket.py From jupyter-server-proxy with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #5
Source File: test_tnd.py From restless with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #6
Source File: test_tnd.py From restless with BSD 3-Clause "New" or "Revised" License | 5 votes |
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