Fix ResourceWarnings

This commit is contained in:
Théo Piboubès
2015-08-20 14:39:45 +02:00
parent e7ad6067d2
commit a2fa9c5ea3
2 changed files with 4 additions and 1 deletions

View File

@@ -18,6 +18,8 @@ from .docs import *
from .oauth import OAuthTool from .oauth import OAuthTool
from .__version__ import __version__ from .__version__ import __version__
from tornado import ioloop
__all__ = [] __all__ = []
def get_config_fp(): def get_config_fp():
@@ -179,5 +181,7 @@ def main():
finally: finally:
# Ensure sockets are closed to prevent a ResourceWarning # Ensure sockets are closed to prevent a ResourceWarning
reddit.handler.http.close() reddit.handler.http.close()
# Explicitly close file descriptors opened by Tornado's IOLoop
ioloop.IOLoop.current().close(all_fds=True)
sys.exit(main()) sys.exit(main())

View File

@@ -141,7 +141,6 @@ class OAuthTool(object):
with self.loader(message='Waiting for authorization'): with self.loader(message='Waiting for authorization'):
webbrowser.open(permission_ask_page_link) webbrowser.open(permission_ask_page_link)
ioloop.IOLoop.current().start() ioloop.IOLoop.current().start()
global oauth_state global oauth_state