Skip to content

Commit

Permalink
Merge pull request #40 from TimoRoth/fix_async_templates
Browse files Browse the repository at this point in the history
Await rendered template if neccesary
  • Loading branch information
jtpio committed Feb 9, 2021
2 parents dbd23a9 + 0c9ca68 commit 3545a64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]
jupyterhub-version: [latest, 1.2.2]

steps:
- uses: actions/checkout@v2
Expand All @@ -28,9 +29,13 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools
python -m pip install -r dev-requirements.txt
python -m pip install -e .
- name: Downgrade jupyterhub
if: ${{ matrix.jupyterhub-version != 'latest' }}
run: |
python -m pip install -U 'jupyterhub==${{ matrix.jupyterhub-version }}'
- name: Run Tests
run: |
python -m pytest --cov
17 changes: 10 additions & 7 deletions tljh_repo2docker/images.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from inspect import isawaitable
from jupyterhub.handlers.base import BaseHandler
from jupyterhub.utils import admin_only
from tornado import web
Expand All @@ -15,11 +16,13 @@ class ImagesHandler(BaseHandler):
async def get(self):
images = await list_images()
containers = await list_containers()
self.write(
self.render_template(
"images.html",
images=images + containers,
default_mem_limit=self.settings.get("default_mem_limit"),
default_cpu_limit=self.settings.get("default_cpu_limit"),
)
result = self.render_template(
"images.html",
images=images + containers,
default_mem_limit=self.settings.get("default_mem_limit"),
default_cpu_limit=self.settings.get("default_cpu_limit"),
)
if isawaitable(result):
self.write(await result)
else:
self.write(result)

0 comments on commit 3545a64

Please sign in to comment.