Ejemplo n.º 1
0
 def setUp(self):
     # Trigger a cleanup of the mapping so we start with a clean slate.
     AsyncIOLoop().close()
     # If we don't clean up after ourselves other tests may fail on
     # py34.
     self.orig_policy = asyncio.get_event_loop_policy()
     asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
Ejemplo n.º 2
0
 def setUp(self):
     # Trigger a cleanup of the mapping so we start with a clean slate.
     AsyncIOLoop().close()
     # If we don't clean up after ourselves other tests may fail on
     # py34.
     self.orig_policy = asyncio.get_event_loop_policy()
     asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
Ejemplo n.º 3
0
 def run_policy_test(self, accessor, expected_type):
     # With the default policy, non-main threads don't get an event
     # loop.
     self.assertRaises(RuntimeError, self.executor.submit(accessor).result)
     # Set the policy and we can get a loop.
     asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())
     self.assertIsInstance(
         self.executor.submit(accessor).result(), expected_type)
     # Clean up to silence leak warnings. Always use asyncio since
     # IOLoop doesn't (currently) close the underlying loop.
     self.executor.submit(lambda: asyncio.get_event_loop().close()).result()
Ejemplo n.º 4
0
 def run_policy_test(self, accessor, expected_type):
     # With the default policy, non-main threads don't get an event
     # loop.
     self.assertRaises(RuntimeError,
                       self.executor.submit(accessor).result)
     # Set the policy and we can get a loop.
     asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())
     self.assertIsInstance(
         self.executor.submit(accessor).result(),
         expected_type)
     # Clean up to silence leak warnings. Always use asyncio since
     # IOLoop doesn't (currently) close the underlying loop.
     self.executor.submit(lambda: asyncio.get_event_loop().close()).result()
Ejemplo n.º 5
0
 def tearDown(self):
     asyncio.set_event_loop_policy(self.orig_policy)
     self.executor.shutdown()
Ejemplo n.º 6
0
 def tearDown(self):
     asyncio.get_event_loop().close()
     asyncio.set_event_loop_policy(self.orig_policy)
Ejemplo n.º 7
0
 def tearDown(self):
     asyncio.set_event_loop_policy(self.orig_policy)
     self.executor.shutdown()
Ejemplo n.º 8
0
 def tearDown(self):
     asyncio.get_event_loop().close()
     asyncio.set_event_loop_policy(self.orig_policy)
Ejemplo n.º 9
0
import tornado.wsgi
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.options import define, options
from tornado.web import Application
from tornado.platform.asyncio import asyncio
from dashboardService.handlers.dashboardRequestHandler import DashboardRequestHandler


define('port', default=8086, help='Port to listen on')

# def main():
"""Construct and serve the tornado application."""
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

app = Application([
    ('/api/.*', DashboardRequestHandler)
])

# application = tornado.wsgi.WSGIAdapter(app)

http_server = HTTPServer(app)
http_server.listen(options.port)
print('Dashboard service listening on http://localhost:%i' % options.port)
IOLoop.current().start()

# if __name__ == '__main__':
#     main()