use run_sync to run coroutines in sync contexts

allows using py.test stuff in spawner/auth tests
This commit is contained in:
MinRK
2014-09-12 15:58:48 -07:00
parent 236612a0aa
commit 67e12c1a5e
5 changed files with 118 additions and 136 deletions

View File

@@ -363,12 +363,8 @@ class JupyterHubApp(Application):
except KeyboardInterrupt:
print("\nInterrupted")
finally:
# have to install/start a new IOLoop briefly,
# to allow for async cleanup code.
IOLoop.clear_instance()
cleanup_loop = IOLoop.instance()
cleanup_loop.add_callback(self.cleanup)
cleanup_loop.start()
# run the cleanup step (in a new loop, because the interrupted one is unclean)
IOLoop().run_sync(self.cleanup)
main = JupyterHubApp.launch_instance