From 8259059119711216c4da428b92f717e3b8c827ba Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 30 Oct 2012 16:37:19 -0400 Subject: [PATCH] runtornado: Remove ability to run without specifying exactly one port The zero-port case never actually worked, because addrport wasn't an optional parameter in run_one. And multiple ports was implemented using the multiprocessing library, which is just bad news. Since we have no need for this, remove it before it can cause trouble. (imported from commit 9d913924701f30d23ebe878b76c8f1f0da2800e2) --- zephyr/management/commands/runtornado.py | 35 ++++-------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/zephyr/management/commands/runtornado.py b/zephyr/management/commands/runtornado.py index 541787a379..f8877f1596 100644 --- a/zephyr/management/commands/runtornado.py +++ b/zephyr/management/commands/runtornado.py @@ -21,43 +21,20 @@ class Command(BaseCommand): help = "Starts a Tornado Web server wrapping Django." args = '[optional port number or ipaddr:port]\n (use multiple ports to start multiple servers)' - def handle(self, *addrport, **options): + def handle(self, addrport, **options): # setup unbuffered I/O sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0) - if len(addrport) == 0: - self.run_one(**options) - elif len(addrport) == 1: - self.run_one(addrport[0], **options) - else: - from multiprocessing import Process - - plist = [] - for ap in addrport: - p = Process(target=self.run_one, args=(ap,), kwargs=options) - p.start() - plist.append(p) - - while plist: - if plist[0].exitcode is None: - plist.pop(0) - else: - plist[0].join() - - def run_one(self, addrport, **options): import django from django.core.handlers.wsgi import WSGIHandler from tornado import httpserver, wsgi, ioloop, web - if not addrport: - addr = '' - port = '8000' - else: - try: - addr, port = addrport.split(':') - except ValueError: - addr, port = '', addrport + try: + addr, port = addrport.split(':') + except ValueError: + addr, port = '', addrport + if not addr: addr = '127.0.0.1'