我们从Python开源项目中,提取了以下19个代码示例,用于说明如何使用gevent.version_info()。
def patch(self): from gevent import monkey monkey.noisy = False # if the new version is used make sure to patch subprocess if gevent.version_info[0] == 0: monkey.patch_all() else: monkey.patch_all(subprocess=True) # monkey patch sendfile to make it none blocking patch_sendfile() # patch sockets sockets = [] for s in self.sockets: if sys.version_info[0] == 3: sockets.append(socket(s.FAMILY, _socket.SOCK_STREAM, fileno=s.sock.fileno())) else: sockets.append(socket(s.FAMILY, _socket.SOCK_STREAM, _sock=s)) self.sockets = sockets
def testcase(): print "Version: ", gevent.version_info gevent.joinall([gevent.spawn(get_data, 'https://python.org/'), gevent.spawn(get_data, 'https://www.yahoo.com/'), gevent.spawn(get_data, 'https://github.com/')])
def gevent_run(app, address, port, debugger=False, reloader=False): from gevent.wsgi import WSGIServer from werkzeug.debug import DebuggedApplication import gevent.monkey gevent.monkey.patch_all() run_app = app if debugger: run_app = DebuggedApplication(app) def run_server(): import logging from gevent import version_info logger = logging.getLogger('pydirl') logger.info('Listening on http://{}:{}/'.format(address, port)) server_params = dict() # starting from gevent version 1.1b1 we can pass custom logger to gevent if version_info[:2] >= (1, 1): server_params['log'] = logger http_server = WSGIServer((address, port), run_app, **server_params) http_server.serve_forever() if reloader: from werkzeug._reloader import run_with_reloader run_with_reloader(run_server) else: run_server()