当前位置: 首页>>代码示例>>Python>>正文


Python IOLoop.configure方法代码示例

本文整理汇总了Python中tornado.ioloop.IOLoop.configure方法的典型用法代码示例。如果您正苦于以下问题:Python IOLoop.configure方法的具体用法?Python IOLoop.configure怎么用?Python IOLoop.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.ioloop.IOLoop的用法示例。


在下文中一共展示了IOLoop.configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main(args):
    parser = argparse.ArgumentParser(
        description="Controller daemon for A/V devices")
    for name, cls in Devices:
        cls.register_args(name, parser)

    IOLoop.configure(AV_Loop, parsed_args=vars(parser.parse_args(args)))
    mainloop = IOLoop.instance()

    for name, cls in Devices:
        try:
            print("*** Initializing %s..." % (cls.Description), end=' ')
            mainloop.add_device(name, cls(mainloop, name))
            print("done")
        except Exception as e:
            print(e)

    if not mainloop.cmd_handlers:
        print("No A/V commands registered. Aborting...")
        return 1

    def cmd_catch_all(empty, cmd):
        """Handle commands that are not handled elsewhere."""
        assert empty == ""
        print("*** Unknown A/V command: '%s'" % (cmd))
    mainloop.add_cmd_handler("", cmd_catch_all)

    print("Starting A/V controller main loop.")
    return mainloop.run()
开发者ID:jherland,项目名称:hifictl,代码行数:31,代码来源:av_control.py

示例2: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main():
    logging.getLogger('tornado.access').propagate = False
    parse_command_line()
    if options.ioloop:
        IOLoop.configure(options.ioloop)
    for _ in range(options.num_runs):
        run()
开发者ID:juniorsilver,项目名称:dokomoforms,代码行数:9,代码来源:benchmark_tornado.py

示例3: configure_ioloop

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
 def configure_ioloop():
     kwargs = {}
     if options.ioloop_time_monotonic:
         from tornado.platform.auto import monotonic_time
         if monotonic_time is None:
             raise RuntimeError("monotonic clock not found")
         kwargs['time_func'] = monotonic_time
     if options.ioloop or kwargs:
         IOLoop.configure(options.ioloop, **kwargs)
开发者ID:102hailan,项目名称:tornado,代码行数:11,代码来源:runtests.py

示例4: __init__

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
    def __init__(self, *args):
        Privilege.init()
        PyExt.init()
        StdChal.init()
        IOLoop.configure(EvIOLoop)

        Server.init_socket_server()

        super().__init__(*args)
开发者ID:pzread,项目名称:judge,代码行数:11,代码来源:TestWebSock.py

示例5: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main():
    '''Main function.'''

    Privilege.init()
    PyExt.init()
    StdChal.init()
    IOLoop.configure(EvIOLoop)

    init_websocket_server()

    IOLoop.instance().start()
开发者ID:ChienYuLu,项目名称:judge,代码行数:13,代码来源:Server.py

示例6: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main():
    '''Main function.'''

    Privilege.init()
    PyExt.init()
    StdChal.init()
    IOLoop.configure(EvIOLoop)

    app = Application([
        (r'/judge', JudgeHandler),
    ])
    app.listen(2501)

    IOLoop.instance().start()
开发者ID:ShikChen,项目名称:judge,代码行数:16,代码来源:Server.py

示例7: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main(args):
    import argparse
    from tornado.ioloop import IOLoop

    from av_loop import AV_Loop

    parser = argparse.ArgumentParser(description=Fake_SerialDevice.Description)
    Fake_SerialDevice.register_args("fake", parser)

    IOLoop.configure(AV_Loop, parsed_args=vars(parser.parse_args(args)))
    mainloop = IOLoop.instance()
    fake = Fake_SerialDevice(mainloop, "fake")

    print("%s is listening on %s" % (
        fake.Description, fake.client_name()))

    return mainloop.run()
开发者ID:jherland,项目名称:hifictl,代码行数:19,代码来源:fake_serial_device.py

示例8: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main(args):
    import argparse
    from tornado.ioloop import IOLoop

    from av_loop import AV_Loop

    parser = argparse.ArgumentParser(description=Fake_AVR.Description)
    Fake_AVR.register_args("avr", parser)

    IOLoop.configure(AV_Loop, parsed_args=vars(parser.parse_args(args)))
    mainloop = IOLoop.instance()
    avr = Fake_AVR(mainloop, "avr")

    print("You can now start ./av_control.py --avr-tty %s" % (
        avr.client_name()))

    return mainloop.run()
开发者ID:jherland,项目名称:hifictl,代码行数:19,代码来源:fake_avr.py

示例9: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main(args):
    import argparse
    from tornado.ioloop import IOLoop

    from av_loop import AV_Loop

    parser = argparse.ArgumentParser(
        description=Fake_HDMI_Switch.Description)
    Fake_HDMI_Switch.register_args("hdmi", parser)

    IOLoop.configure(AV_Loop, parsed_args=vars(parser.parse_args(args)))
    mainloop = IOLoop.instance()
    hdmi = Fake_HDMI_Switch(mainloop, "hdmi")

    print("You can now start ./av_control.py --hdmi-tty %s" % (
        hdmi.client_name()))

    return mainloop.run()
开发者ID:jherland,项目名称:hifictl,代码行数:20,代码来源:fake_hdmi_switch.py

示例10: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main(args):
    import os
    import argparse
    from tornado.ioloop import IOLoop

    from av_loop import AV_Loop

    parser = argparse.ArgumentParser(
        description="Communicate with " + HDMI_Switch.Description)
    HDMI_Switch.register_args("hdmi", parser)

    IOLoop.configure(AV_Loop, parsed_args=vars(parser.parse_args(args)))
    mainloop = IOLoop.instance()
    hdmi = HDMI_Switch(mainloop, "hdmi")

    def print_serial_data(data):
        if data:
            print(data, end=' ')
            if not data.endswith(">"):
                print()
    hdmi.input_handler = print_serial_data

    # Forward commands from stdin to avr
    def handle_stdin(fd, events):
        assert fd == sys.stdin.fileno()
        assert events & mainloop.READ
        cmds = str(os.read(sys.stdin.fileno(), 64 * 1024), 'ascii')
        for cmd in cmds.split("\n"):
            cmd = cmd.strip()
            if cmd:
                print(" -> Received cmd '%s'" % (cmd))
                mainloop.submit_cmd(cmd)
    mainloop.add_handler(sys.stdin.fileno(), handle_stdin, mainloop.READ)

    def cmd_catch_all(empty, cmd):
        assert empty == ""
        print("*** Unknown command: '%s'" % (cmd))
    mainloop.add_cmd_handler("", cmd_catch_all)

    for arg in args:
        mainloop.submit_cmd(arg)

    print("Write HDMI switch commands to stdin (Ctrl-C to stop me)")
    return mainloop.run()
开发者ID:jherland,项目名称:hifictl,代码行数:46,代码来源:hdmi_switch.py

示例11: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main():
    define('host', default='127.0.0.1', help='run on the given host', type=str)
    define('port', default=8000, help='run on the given port', type=int)
    define('debug', default=False, help='enable debug mode', type=bool)
    parse_command_line()

    settings = {
        'debug': options.debug,
        'cookie_secret': os.urandom(32),
        'template_path': resolve('./templates'),
        'static_path': resolve('./static'),
    }

    application = Application(routes, **settings)
    application.listen(options.port, options.host, xheaders=True)

    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
    IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
    print('» listen to http://%s:%s' % (options.host, options.port))
    IOLoop.instance().start()
开发者ID:dhcmrlchtdj,项目名称:shortener.js,代码行数:22,代码来源:main.py

示例12: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main(args):
    import argparse
    from tornado.ioloop import IOLoop

    from av_loop import AV_Loop

    parser = argparse.ArgumentParser(
        description="Communicate with " + AV_HTTPServer.Description)
    AV_HTTPServer.register_args("http", parser)

    IOLoop.configure(AV_Loop, parsed_args=vars(parser.parse_args(args)))
    mainloop = IOLoop.instance()
    httpd = AV_HTTPServer(mainloop, "http")

    def cmd_catch_all(empty, cmd):
        assert empty == ""
        print(" -> cmd_catch_all(%s)" % (cmd))
    mainloop.add_cmd_handler("", cmd_catch_all)

    print("Browse to http://%s:%u/ (Ctrl-C here to stop me)" % (
        httpd.server_host or "localhost", httpd.server_port))
    return mainloop.run()
开发者ID:jherland,项目名称:hifictl,代码行数:24,代码来源:http_server.py

示例13: main

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
def main(args):
    import os
    import argparse
    from tornado.ioloop import IOLoop

    from av_loop import AV_Loop

    parser = argparse.ArgumentParser(
        description="Communicate with " + AVR_Device.Description)
    AVR_Device.register_args("avr", parser)

    IOLoop.configure(AV_Loop, parsed_args=vars(parser.parse_args(args)))
    mainloop = IOLoop.instance()
    AVR_Device(mainloop, "avr")

    # Forward commands from stdin to avr
    def handle_stdin(fd, events):
        assert fd == sys.stdin.fileno()
        assert events & mainloop.READ
        cmds = os.read(sys.stdin.fileno(), 64 * 1024)
        for cmd in cmds.split("\n"):
            cmd = cmd.strip()
            if cmd:
                print(" -> Received cmd '%s'" % (cmd))
                mainloop.submit_cmd(cmd)
    mainloop.add_handler(sys.stdin.fileno(), handle_stdin, mainloop.READ)

    def cmd_catch_all(empty, cmd):
        assert empty == ""
        print("*** Unknown command: '%s'" % (cmd))
    mainloop.add_cmd_handler("", cmd_catch_all)

    for arg in args:
        mainloop.submit_cmd(arg)

    print("Write AVR commands to stdin (Ctrl-C to stop me)")
    return mainloop.run()
开发者ID:jherland,项目名称:hifictl,代码行数:39,代码来源:avr_device.py

示例14: TornadoBoilerplate

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
#!/usr/bin/env python

import tornado.httpserver

from tornado.httpclient import AsyncHTTPClient

from tornado.ioloop import IOLoop
from tornado_pyuv import UVLoop
IOLoop.configure(UVLoop)

from tornado.escape import json_encode
import cjson
import tornado.web
import socket
from tornado.options import options

from settings import settings
from urls import url_patterns
import urllib


class TornadoBoilerplate(tornado.web.Application):
    def __init__(self):
        tornado.web.Application.__init__(self, url_patterns, **settings)
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect((viceIp, vicePort))
        address = s.getsockname()[0]
        body = cjson.encode(Status(address))
        headers = {"Content-Type": "application/json"}
        print body
        request = tornado.httpclient.HTTPRequest(url='%s/frontend_test.php/role_status' % viceServer, method='POST', body=body, headers=headers)
开发者ID:tijmenNL,项目名称:iptv-grabber,代码行数:33,代码来源:app.py

示例15: start

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import configure [as 别名]
 def start(self):
     IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
     IOLoop.instance().start()
开发者ID:gonicus,项目名称:gosa,代码行数:5,代码来源:httpd.py


注:本文中的tornado.ioloop.IOLoop.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。