Skip to content

Commit

Permalink
updates to tornado 3.1 , also separates hellotornado.py from app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gfidente committed Jun 30, 2013
1 parent dcb11d6 commit dc49b9b
Show file tree
Hide file tree
Showing 91 changed files with 13,205 additions and 4,416 deletions.
2 changes: 1 addition & 1 deletion .openshift/action_hooks/stop
@@ -1,4 +1,4 @@
#!/bin/bash
# The logic to stop your application should be put in this script.
kill `ps -ef | grep hellotornado | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1
exit 0
exit 0
27 changes: 7 additions & 20 deletions README.creole
Expand Up @@ -48,37 +48,24 @@ Activate your virtualenv and install the needed modules:
source misc/virtenv/bin/activate
pip install tornado
pip install futures
pip install pycurl
}}}

Now create your diy/hellotornado.py file:
Now, assuming your app is in app.py, create your start file (diy/hellotornado.py):

{{{
#!/usr/bin/env python
import os
here = os.path.dirname(os.path.abspath(__file__))
os.environ['PYTHON_EGG_CACHE'] = os.path.join(here, '..', 'misc/virtenv/lib/python2.6/site-packages')
virtualenv = os.path.join(here, '..', 'misc/virtenv/bin/activate_this.py')
cwd = os.path.dirname(os.path.abspath(__file__))
os.environ['PYTHON_EGG_CACHE'] = os.path.join(cwd, '..', 'misc/virtenv/lib/python2.6/site-packages')
virtualenv = os.path.join(cwd, '..', 'misc/virtenv/bin/activate_this.py')
execfile(virtualenv, dict(__file__=virtualenv))
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
address = os.environ['OPENSHIFT_DIY_IP']
application.listen(8080, address=address)
tornado.ioloop.IOLoop.instance().start()
import app
app.main(os.environ['OPENSHIFT_DIY_IP'])
}}}

Expand Down
18 changes: 18 additions & 0 deletions diy/app.py
@@ -0,0 +1,18 @@
import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")

application = tornado.web.Application([
(r"/", MainHandler),
])

def main(address):
application.listen(8080, address)
tornado.ioloop.IOLoop.instance().start()

if __name__ == "__main__":
address = "127.0.0.1"
main(address)
24 changes: 5 additions & 19 deletions diy/hellotornado.py
@@ -1,23 +1,9 @@
#!/usr/bin/env python
import os

here = os.path.dirname(os.path.abspath(__file__))
os.environ['PYTHON_EGG_CACHE'] = os.path.join(here, '..', 'misc/virtenv/lib/python2.6/site-packages')
virtualenv = os.path.join(here, '..', 'misc/virtenv/bin/activate_this.py')
cwd = os.path.dirname(os.path.abspath(__file__))
os.environ['PYTHON_EGG_CACHE'] = os.path.join(cwd, '..', 'misc/virtenv/lib/python2.6/site-packages')
virtualenv = os.path.join(cwd, '..', 'misc/virtenv/bin/activate_this.py')
execfile(virtualenv, dict(__file__=virtualenv))

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")

application = tornado.web.Application([
(r"/", MainHandler),
])

if __name__ == "__main__":
address = os.environ['OPENSHIFT_DIY_IP']
application.listen(8080, address=address)
tornado.ioloop.IOLoop.instance().start()
import app
app.main(os.environ['OPENSHIFT_DIY_IP'])
@@ -0,0 +1,3 @@
from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)
@@ -0,0 +1,18 @@
# Copyright 2009 Brian Quinlan. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Execute computations asynchronously using threads or processes."""

__author__ = 'Brian Quinlan (brian@sweetapp.com)'

from concurrent.futures._base import (FIRST_COMPLETED,
FIRST_EXCEPTION,
ALL_COMPLETED,
CancelledError,
TimeoutError,
Future,
Executor,
wait,
as_completed)
from concurrent.futures.process import ProcessPoolExecutor
from concurrent.futures.thread import ThreadPoolExecutor

0 comments on commit dc49b9b

Please sign in to comment.