1515from snekbox .memfs import MemFS
1616from snekbox .process import EvalResult
1717from snekbox .snekio import FileAttachment
18- from snekbox .utils .timed import timed
18+ from snekbox .utils .timed import time_limit
1919
2020__all__ = ("NsJail" ,)
2121
@@ -267,16 +267,14 @@ def python3(
267267
268268 # Parse attachments with time limit
269269 try :
270- attachments = timed (
271- MemFS .files_list ,
272- (fs , self .files_limit , self .files_pattern ),
273- {
274- "preload_dict" : True ,
275- "exclude_files" : files_written ,
276- "timeout" : self .files_timeout ,
277- },
278- timeout = self .files_timeout ,
279- )
270+ with time_limit (self .files_timeout ):
271+ attachments = fs .files_list (
272+ limit = self .files_limit ,
273+ pattern = self .files_pattern ,
274+ preload_dict = True ,
275+ exclude_files = files_written ,
276+ timeout = self .files_timeout ,
277+ )
280278 log .info (f"Found { len (attachments )} files." )
281279 except RecursionError :
282280 log .info ("Recursion error while parsing attachments" )
@@ -290,6 +288,11 @@ def python3(
290288 return EvalResult (
291289 args , None , "TimeoutError: Exceeded time limit while parsing attachments"
292290 )
291+ except Exception as e :
292+ log .error (f"Unexpected { type (e ).__name__ } while parse attachments: { e } " )
293+ return EvalResult (
294+ args , None , "FileParsingError: Unknown error while parsing attachments"
295+ )
293296
294297 log_lines = nsj_log .read ().decode ("utf-8" ).splitlines ()
295298 if not log_lines and returncode == 255 :
0 commit comments