From a2fa9c5ea3eb3d419c777dad04d6a42081f97a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Piboub=C3=A8s?= Date: Thu, 20 Aug 2015 14:39:45 +0200 Subject: [PATCH] Fix ResourceWarnings --- rtv/__main__.py | 4 ++++ rtv/oauth.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rtv/__main__.py b/rtv/__main__.py index 27c0387..881feff 100644 --- a/rtv/__main__.py +++ b/rtv/__main__.py @@ -18,6 +18,8 @@ from .docs import * from .oauth import OAuthTool from .__version__ import __version__ +from tornado import ioloop + __all__ = [] def get_config_fp(): @@ -179,5 +181,7 @@ def main(): finally: # Ensure sockets are closed to prevent a ResourceWarning reddit.handler.http.close() + # Explicitly close file descriptors opened by Tornado's IOLoop + ioloop.IOLoop.current().close(all_fds=True) sys.exit(main()) diff --git a/rtv/oauth.py b/rtv/oauth.py index 81399de..0d3029c 100644 --- a/rtv/oauth.py +++ b/rtv/oauth.py @@ -141,7 +141,6 @@ class OAuthTool(object): with self.loader(message='Waiting for authorization'): webbrowser.open(permission_ask_page_link) - ioloop.IOLoop.current().start() global oauth_state