Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
# Mark as finished
self.finished_at = sqlalchemy.func.current_timestamp()
+ # Flush and refresh
+ await self.db.flush_and_refresh(self)
+
# Mark as failed if the build was not successful
if not success:
self.failed = True
# Refresh!
await session.refresh(o)
+ async def flush_and_refresh(self, *objects):
+ """
+ Flushes and refreshes in one go.
+ """
+ # Fetch our session
+ session = await self.session()
+
+ # Flush!
+ await session.flush(objects)
+
+ # Refresh!
+ for o in objects:
+ 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)
+ # Flush to the database and read back the timestamp
+ await self.db.flush_and_refresh(self)
# Import log
if logfile: