예제 #1
0
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()
예제 #2
0
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()
예제 #3
0
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()
예제 #4
0
파일: TestWebSock.py 프로젝트: pzread/judge
    def __init__(self, *args):
        Privilege.init()
        PyExt.init()
        StdChal.init()
        IOLoop.configure(EvIOLoop)

        Server.init_socket_server()

        super().__init__(*args)
예제 #5
0
    def __init__(self, *args):
        Privilege.init()
        PyExt.init()
        StdChal.init()
        IOLoop.configure(EvIOLoop)

        Server.init_socket_server()

        super().__init__(*args)
예제 #6
0
 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)
예제 #7
0
 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)
예제 #8
0
def main():
    IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
    router = RuleRouter([Rule(PathMatches(r"/.*"), MyApplication())])
    server = HTTPServer(router,
                        ssl_options={
                            "certfile": str(cert),
                            "keyfile": str(key),
                        })
    server.listen(443)
    IOLoop.instance().start()
예제 #9
0
파일: Server.py 프로젝트: ChienYuLu/judge
def main():
    '''Main function.'''

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

    init_websocket_server()

    IOLoop.instance().start()
예제 #10
0
def main():
    '''Main function.'''

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

    init_socket_server()

    IOLoop.instance().start()
예제 #11
0
def run():
    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
    IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
    app = Application([(r'/', HelloWorldHandler),
                       (r"/quote/?", SharknadoQuote),
                       (r'/sleep/?', TimerHandler),
                       (r'/hello/(?P<name>.+)/?', HelloNameHandler)])
    server = HTTPServer(app)
    server.bind(8888)
    server.start(0)
    IOLoop.current().start()
예제 #12
0
def make_app(uvloop=False):
    if uvloop:
        IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
        import asyncio
        import uvloop
        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
    return tornado.web.Application([
        (r'/sleep50', SimpleHandler),
        (r'/oldstyle50', OldStyleHandler),
        (r'/hard_work', HardWorkHandler),
        (r'/hard_work_oldstyle', HardWorkHandlerOldStyle),
    ])
예제 #13
0
    def get_new_ioloop(self):
        """Override the creation of the IOLoop mimicking that of application.

        The result needs to be a Tornado IOLoop instance, we first configure
        the asyncio loop and then call IOLoop configure to use it.

        """
        if sys.platform == 'linux':
            selector = selectors.SelectSelector()
            loop = asyncio.SelectorEventLoop(selector)
            asyncio.set_event_loop(loop)

        IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
        return IOLoop.current()
예제 #14
0
파일: Server.py 프로젝트: ShikChen/judge
def main():
    '''Main function.'''

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

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

    IOLoop.instance().start()
예제 #15
0
def main():
    '''Main function.'''

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

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

    IOLoop.instance().start()
예제 #16
0
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()
예제 #17
0
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()
예제 #18
0
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()
예제 #19
0
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()
예제 #20
0
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()
예제 #21
0
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()
예제 #22
0
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()
예제 #23
0
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()
예제 #24
0
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()
예제 #25
0
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()
예제 #26
0
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()
예제 #27
0
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()
예제 #28
0
#!/usr/bin/env python

import json
import motor
import tornado.ioloop
import tornado.web
import tornado.httpserver

from random import randint
from tornado.options import options
from commons import JsonHandler, JsonHelloWorldHandler, PlaintextHelloWorldHandler, HtmlHandler
from tornado.ioloop import IOLoop

IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')


options.define('port', default=8888, type=int, help="Server port")
options.define('mongo', default='localhost', type=str, help="MongoDB host")
options.define('backlog', default=8192, type=int, help="Server backlog")


class SingleQueryHandler(JsonHandler):

    async def get(self):
        world = await db.world.find_one(randint(1, 10000))
        world = {self.ID: int(world['_id']),
                 self.RANDOM_NUMBER: int(world[self.RANDOM_NUMBER])
                 }

        response = json.dumps(world)
        self.finish(response)
예제 #29
0
if not os.path.exists('config.py'):
    contents = """#!/usr/bin/python3
import multiprocessing

PORT = 8080
CACHE_DIR = 'cache'
MAX_WORKERS = multiprocessing.cpu_count()
LAYER_DIR = 'examples'
# LAYER_DIR = 'data'
STYLESHEET = 'stylesheet.xml'"""
    with open('config.py', 'w') as fileHandler:
        fileHandler.write(contents)

import config
from router import router

define("port", default=str(config.PORT), help="Server port")

if __name__ == "__main__":
    options.parse_command_line()
    app = router()
    app.listen(options.port)
    print('{0}-{1}.{2}.{3}'.format(SERVICE, VERSION['major'], VERSION['minor'],
                                   VERSION['patch']))
    print("Magic happens on http://localhost:" + options.port)
    try:
        IOLoop.configure(TornadoUvloop)
    except NameError:
        pass
    IOLoop.current().start()
예제 #30
0
def run():
    IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
    app = Application([(r'/sleep/?', TimerHandler)])
    app.listen(8888)
    IOLoop.current().start()
예제 #31
0
파일: httpd.py 프로젝트: gonicus/gosa
 def start(self):
     IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
     IOLoop.instance().start()
예제 #32
0
def main():
    parse_command_line()
    if options.ioloop:
        IOLoop.configure(options.ioloop)
    for i in xrange(options.num_runs):
        run()
예제 #33
0
 def instrument_tornado_ioloop():
     IOLoop.configure(InstrumentedPollIOLoop)
예제 #34
0
파일: TestDiff.py 프로젝트: LFsWang/judge
 def get_new_ioloop(self):
     IOLoop.configure(EvIOLoop)
     return IOLoop().instance()
예제 #35
0
 def get_new_ioloop(self):
     IOLoop.configure(EvIOLoop)
     return IOLoop().instance()
예제 #36
0
파일: benchmark.py 프로젝트: 1-alex/tornado
def main():
    parse_command_line()
    if options.ioloop:
        IOLoop.configure(options.ioloop)
    for i in xrange(options.num_runs):
        run()
예제 #37
0
        register = next(self._register)
        log.debug('_send_request(%d)', register)
        self._timeout_callback = IOLoop.current().call_later(self._timeout, self._on_timeout)
        log.debug('+++ timeout set: %s', self._timeout_callback)
        try:
            self._client.read_holding_registers(register, 1, unit=UNIT).addCallback(functools.partial(self._on_done, register))
        except StreamClosedError as ex:
            log.exception(ex)
        except Exception as ex:
            log.exception(ex)

    def _on_done(self, register, f):
        log.debug('_on_done(%d)', register)
        if isinstance(f, ReadHoldingRegistersResponse):
            self._print(register, f.registers)
        elif isinstance(f, AsyncErrorResponse):
            log.error("AsyncErrorResponse error_code = %d", f.error_code)
        else:
            log.error("Unknown error: register: %s, f: %s", register, f)
        log.debug('--- remove_timeout()')
        IOLoop.current().remove_timeout(self._timeout_callback)
        self._send_request()


if __name__ == "__main__":
    IOLoop.configure('tornado.platform.epoll.EPollIOLoop')
#   ModBusRunner('local', AsyncModbusTCPClient, [8, 10], host='127.0.0.1', port=5020)
    ModBusRunner('tcp', AsyncModbusTCPClient, [149, 150, 257, 498, 499], host='192.168.1.151', port=502)
    ModBusRunner120('serial', AsyncModbusSerialClient, [149, 150, 257, 498, 499], method='rtu', port='/dev/ttyUSB2', baudrate=19200, parity='E')
    IOLoop.instance().start()
예제 #38
0
 def setUp(self):
     IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
     super().setUp()
예제 #39
0
import os

from raven.contrib.tornado import AsyncSentryClient

from tornado.httpserver import HTTPServer
from tornado.options import parse_command_line
from tornado import web
from tornado.ioloop import IOLoop
from urllib.parse import urlparse
IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')


import momoko

from .application import handlers as send_handlers
from .base.base_handlers import PingHandler


ioloop = IOLoop.instance()


application = web.Application([
    (r'/drafts/', send_handlers.ImportDraftsListHandler),
    (r'/ping/', PingHandler),
], debug=True)


port = int(os.environ.get('PORT', 8000))
defaultdburl = 'postgres://*****:*****@localhost:5432/project_prj_db'
dburl = urlparse(os.environ.get("DATABASE_URL", defaultdburl))
예제 #40
0
"""Entrypoint for running the kernel process."""
from spylon_kernel import SpylonKernel
from tornado.ioloop import IOLoop

if __name__ == '__main__':
    IOLoop.configure("tornado.platform.asyncio.AsyncIOLoop")
    SpylonKernel.run_as_main()
예제 #41
0
    def setUp(self):
        super().setUp()

        IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
        self.io_loop = IOLoop.current()
예제 #42
0
파일: server.py 프로젝트: justzx2011/selene
# -*- coding: utf-8 *-*
import logging
import pymongo
import tornado.web
import tornado.httpserver

from tornado.ioloop import IOLoop
from tornado.options import options as opts
from selene import log, options, Selene, web

if __name__ == '__main__':
    options.setup_options('selene.conf')
    if not opts.db_rs:
        db = pymongo.MongoClient(opts.db_uri)[opts.db_name]
        logging.info('Connected to a MongoDB standalone instance.')
    else:
        db = pymongo.MongoReplicaSetClient(
            opts.db_uri, replicaSet=opts.db_rs_name)[opts.db_name]
        logging.info('Connected to a MongoDB replica set.')
    if opts.logging_db:
        log.configure_mongolog()
    http_server = tornado.httpserver.HTTPServer(Selene(db))
    tornado.web.ErrorHandler = web.ErrorHandler
    http_server.listen(opts.port)
    logging.info('Web server listening on %s port.' % opts.port)
    if opts.use_pyuv:
        from tornado_pyuv import UVLoop
        IOLoop.configure(UVLoop)
    loop = IOLoop.instance()
    loop.start()
예제 #43
0
def instrument_tornado_ioloop() -> None:
    IOLoop.configure(InstrumentedPollIOLoop)
예제 #44
0
from tornado.ioloop import IOLoop

IOLoop.configure('apps.base.ioloop.IOLoop')
예제 #45
0
 def get_new_ioloop(self):
     IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
     instance = IOLoop.instance()
     return instance
예제 #46
0
 def instrument_tornado_ioloop():
     # type: () -> None
     IOLoop.configure(InstrumentedPollIOLoop)
예제 #47
0
#!/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)
예제 #48
0
파일: httpd.py 프로젝트: GOsa3/gosa
 def start(self):
     IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
     IOLoop.instance().start()