Created
May 29, 2013 22:12
-
-
Save Lothiraldan/5674257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import socket | |
from tornado.web import Application as BaseApplication | |
from tornado.options import define, options, parse_command_line | |
class Application(BaseApplication): | |
def listen(self, port, address="", **kwargs): | |
if options.fd: | |
from tornado.httpserver import HTTPServer | |
sock = socket.fromfd(options.fd, socket.AF_INET, socket.SOCK_STREAM) | |
#sock.set_blocking(0) | |
server = HTTPServer(self, **kwargs) | |
server.add_socket(sock) | |
else: | |
super(Application, self).listen(port, address, **kwargs) | |
define("fd", default=None, help="File Descriptor given by circus", type=int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment