]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make autoreload close the IOLoop through the standard interface.
authorBen Darnell <ben@bendarnell.com>
Sun, 20 Jan 2013 20:46:01 +0000 (15:46 -0500)
committerBen Darnell <ben@bendarnell.com>
Sun, 20 Jan 2013 20:59:10 +0000 (15:59 -0500)
This makes it compatible with TwistedIOLoop.

tornado/autoreload.py

index e18ecc0d62393315a365bc892dd4e8948a049b28..4e424878f1f5994a35afd3b5dc87e23c57d2a908 100644 (file)
@@ -105,7 +105,7 @@ def start(io_loop=None, check_time=500):
     _io_loops[io_loop] = True
     if len(_io_loops) > 1:
         gen_log.warning("tornado.autoreload started more than once in the same process")
-    add_reload_hook(functools.partial(_close_all_fds, io_loop))
+    add_reload_hook(functools.partial(io_loop.close, all_fds=True))
     modify_times = {}
     callback = functools.partial(_reload_on_update, modify_times)
     scheduler = ioloop.PeriodicCallback(callback, check_time, io_loop=io_loop)
@@ -143,14 +143,6 @@ def add_reload_hook(fn):
     _reload_hooks.append(fn)
 
 
-def _close_all_fds(io_loop):
-    for fd in io_loop._handlers.keys():
-        try:
-            os.close(fd)
-        except Exception:
-            pass
-
-
 def _reload_on_update(modify_times):
     if _reload_attempted:
         # We already tried to reload and it didn't work, so don't try again.