# Commit!
await session.commit()
+ async def flush(self, *objects):
+ """
+ Manually triggers a flush
+ """
+ # Fetch our session
+ session = await self.session()
+
+ # Flush!
+ await session.flush(objects)
+
+ async def refresh(self, o):
+ """
+ Refreshes the given object
+ """
+ # Fetch our session
+ session = await self.session()
+
+ # Refresh!
+ await session.refresh(o)
+
class BackendMixin:
@functools.cached_property
# Store the time
self.finished_at = sqlalchemy.func.current_timestamp()
+ # Flush to the database
+ await self.db.flush(self)
+
+ # Read back the timestamp so that we won't trigger
+ # a read from synchronous code later.
+ await self.db.refresh(self)
+
# Import log
if logfile:
await self._import_logfile(logfile)
"""
Returns True if this job has finished, been aborted, etc.
"""
- # This check is checking if finished_at is set because SQLAlchemy is behaving
- # a little bit stupid when we set finished_at to sqlalchemy.func.current_timestamp()
- # because since this is a server function, it cannot know the value before we commit.
- if self.finished_at is None:
- return False
+ if self.finished_at:
+ return True
- return True
+ return False
# Failed