File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 66from functools import cached_property
77import logging
88from pathlib import Path
9+ import random
910from secrets import token_hex
1011import secrets
1112import shutil
1213import tarfile
14+ import time
1315import typing
1416import uuid
1517import lxml .etree
@@ -193,7 +195,7 @@ async def run(self):
193195 await asyncio .sleep (self .poll_interval )
194196 if self .auto_import :
195197 await self .schedule_waiting ()
196- await self .cleanup ()
198+ await self .cleanup ()
197199 except asyncio .CancelledError :
198200 raise
199201 except BaseException :
@@ -204,7 +206,13 @@ async def run(self):
204206
205207 async def schedule_waiting (self ):
206208 """Pick up waiting tasks from inbox"""
209+ # Only pick up older files for which we are sure the regular
210+ # improt didn't work or was aborted.
211+ min_age = random .randint (60 ,120 )
212+
207213 for file in self .inbox_dir .glob ("*.tar" ):
214+ if file .stat ().st_mtime + min_age > time .time ():
215+ continue
208216 self ._schedule (RecordingImportTask (self , file .stem , file ))
209217
210218 async def cleanup (self ):
You can’t perform that action at this time.
0 commit comments