Skip to content

Commit

Permalink
Scope SQLA session so object lifespans rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdz authored and rjcortese committed Apr 27, 2022
1 parent 46b28c2 commit d071632
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions luigi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,28 +245,32 @@ def from_utc(utcTime, fmt=None):

class RecentRunHandler(BaseTaskHistoryHandler):
def get(self):
tasks = self._scheduler.task_history.find_latest_runs()
self.render("recent.html", tasks=tasks)
with self._scheduler.task_history._session(None) as session:
tasks = self._scheduler.task_history.find_latest_runs(session)
self.render("recent.html", tasks=tasks)


class ByNameHandler(BaseTaskHistoryHandler):
def get(self, name):
tasks = self._scheduler.task_history.find_all_by_name(name)
self.render("recent.html", tasks=tasks)
with self._scheduler.task_history._session(None) as session:
tasks = self._scheduler.task_history.find_all_by_name(name, session)
self.render("recent.html", tasks=tasks)


class ByIdHandler(BaseTaskHistoryHandler):
def get(self, id):
task = self._scheduler.task_history.find_task_by_id(id)
self.render("show.html", task=task)
with self._scheduler.task_history._session(None) as session:
task = self._scheduler.task_history.find_task_by_id(id, session)
self.render("show.html", task=task)


class ByParamsHandler(BaseTaskHistoryHandler):
def get(self, name):
payload = self.get_argument('data', default="{}")
arguments = json.loads(payload)
tasks = self._scheduler.task_history.find_all_by_parameters(name, session=None, **arguments)
self.render("recent.html", tasks=tasks)
with self._scheduler.task_history._session(None) as session:
tasks = self._scheduler.task_history.find_all_by_parameters(name, session=session, **arguments)
self.render("recent.html", tasks=tasks)


class RootPathHandler(BaseTaskHistoryHandler):
Expand Down

0 comments on commit d071632

Please sign in to comment.