Skip to content

Commit 8b0dafa

Browse files
committed
Don't pass ioloop around app, only pass to BuildExecutor
1 parent 99a8ac8 commit 8b0dafa

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

binderhub/app.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from tornado.httpserver import HTTPServer
2727
from tornado.log import app_log
2828
from traitlets import (
29-
Any,
3029
Bool,
3130
Bytes,
3231
Dict,
@@ -701,8 +700,6 @@ def _template_path_default(self):
701700
help="Origin to use when emitting events. Defaults to hostname of request when empty",
702701
)
703702

704-
ioloop = Any(help="Event loop to use")
705-
706703
@staticmethod
707704
def add_url_prefix(prefix, handlers):
708705
"""add a url prefix to handlers"""
@@ -730,7 +727,6 @@ def init_pycurl(self):
730727
def initialize(self, *args, **kwargs):
731728
"""Load configuration settings."""
732729
super().initialize(*args, **kwargs)
733-
self.ioloop = tornado.ioloop.IOLoop.current()
734730
self.load_config_file(self.config_file)
735731
# hook up tornado logging
736732
if self.debug:
@@ -843,7 +839,6 @@ def initialize(self, *args, **kwargs):
843839
"auth_enabled": self.auth_enabled,
844840
"event_log": self.event_log,
845841
"normalized_origin": self.normalized_origin,
846-
"ioloop": self.ioloop,
847842
}
848843
)
849844
if self.auth_enabled:
@@ -965,7 +960,7 @@ def start(self, run_loop=True):
965960
if self.builder_required:
966961
asyncio.ensure_future(self.watch_build_pods())
967962
if run_loop:
968-
self.ioloop.start()
963+
tornado.ioloop.IOLoop.current().start()
969964

970965

971966
main = BinderHub.launch_instance

binderhub/builder.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from prometheus_client import Counter, Gauge, Histogram
1616
from tornado import gen
1717
from tornado.httpclient import HTTPClientError
18+
from tornado.ioloop import IOLoop
1819
from tornado.iostream import StreamClosedError
1920
from tornado.log import app_log
2021
from tornado.queues import Queue
@@ -259,7 +260,7 @@ async def get(self, provider_prefix, _unescaped_spec):
259260
return
260261

261262
# create a heartbeat
262-
self.settings["ioloop"].spawn_callback(self.keep_alive)
263+
IOLoop.current().spawn_callback(self.keep_alive)
263264

264265
spec = spec.rstrip("/")
265266
key = f"{provider_prefix}:{spec}"
@@ -446,7 +447,7 @@ async def get(self, provider_prefix, _unescaped_spec):
446447
git_credentials=provider.git_credentials,
447448
sticky_builds=self.settings["sticky_builds"],
448449
)
449-
build.main_loop = self.settings["ioloop"]
450+
build.main_loop = IOLoop.current()
450451
else:
451452
build = BuildClass(
452453
# Commented properties should be set in traitlets config
@@ -467,7 +468,7 @@ async def get(self, provider_prefix, _unescaped_spec):
467468
# log_tail_lines=self.settings["log_tail_lines"],
468469
git_credentials=provider.git_credentials,
469470
# sticky_builds=self.settings["sticky_builds"],
470-
main_loop=self.settings["ioloop"],
471+
main_loop=IOLoop.current(),
471472
)
472473
self.build = build
473474

@@ -492,7 +493,7 @@ def _check_result(future):
492493
# Start building
493494
submit_future = pool.submit(build.submit)
494495
submit_future.add_done_callback(_check_result)
495-
self.settings["ioloop"].add_callback(lambda: submit_future)
496+
IOLoop.current().add_callback(lambda: submit_future)
496497

497498
log_future = None
498499

0 commit comments

Comments
 (0)