Skip to content

Commit fb959c4

Browse files
committed
Attempt using nested transaction
1 parent 7a5b566 commit fb959c4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ async def repeat_url_worker():
152152
for job in jobs:
153153
if (not job.url.last_seen or job.url.last_seen + datetime.timedelta(seconds=job.interval) < curtime) and job.url.url not in existing_jobs: # Job can be re-queued
154154
if batch is None or (created_at + datetime.timedelta(minutes=30) < curtime):
155-
# batch = await Batch.objects.create()
156-
batch = Batch()
157-
created_at = curtime
158-
session.add(batch)
155+
async with session.begin_nested():
156+
batch = Batch()
157+
created_at = curtime
158+
session.add(batch)
159159
queued.append(Job(url=job.url, priority=10, batches=[batch, job.batch]))
160160
if queued:
161161
session.add_all(queued)

0 commit comments

Comments
 (0)