Skip to content

Commit

Permalink
fix fileobject close
Browse files Browse the repository at this point in the history
  • Loading branch information
datawhores committed Nov 15, 2023
1 parent 4750fc9 commit ef087d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ofscraper/utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ async def inner(c,ele,path,username,model_id,progress,total):
log.debug(f"[bold] {get_medialog(ele)} main download headers [/bold]: {r.headers}")
r.raise_for_status()
progress.remove_task(task1)
fileobject.close()
await fileobject.close()
size_checker(temp,ele,total)
await asyncio.get_event_loop().run_in_executor(cache_thread,partial( cache.touch,f"{ele.filename}_headers",1))
return total ,temp,path_to_file
Expand All @@ -410,7 +410,7 @@ async def inner(c,ele,path,username,model_id,progress,total):
except Exception as E:
log.traceback(traceback.format_exc())
log.traceback(E)
raise Ef
raise E
finally:
#Close file if needed
try:
Expand Down Expand Up @@ -597,6 +597,7 @@ async def inner(item,c,ele,progress):
log.debug(f"[bold] {get_medialog(ele)} main download data finder headeers [/bold]: {l.headers}")
l.raise_for_status()
progress.remove_task(task1)
await fileobject.close()
size_checker(temp,ele,total)
await asyncio.get_event_loop().run_in_executor(cache_thread,partial( cache.touch,f"{item['name']}_headers",1))
return item
Expand Down
4 changes: 2 additions & 2 deletions ofscraper/utils/downloadbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ async def inner(c,ele,path,username,model_id,total):
innerlog.get().debug(f"[bold] {get_medialog(ele)} main download response text [/bold]: {await r.text_()}")
innerlog.get().debug(f"[bold] {get_medialog(ele)}main download headers [/bold]: {r.headers}")
r.raise_for_status()
fileobject.close()
await fileobject.close()
size_checker(temp,ele,total)
await asyncio.get_event_loop().run_in_executor(cache_thread,partial( cache.touch,f"{ele.filename}_headers",1))
return total,temp,path_to_file
Expand Down Expand Up @@ -770,7 +770,7 @@ async def inner(item,c,ele):
innerlog.get().debug(f"[bold] {get_medialog(ele)} main download data finder text [/bold]: {await l.text_()}")
innerlog.get().debug(f"[bold] {get_medialog(ele)} main download data finder headeers [/bold]: {l.headers}")
l.raise_for_status()
fileobject.close()
await fileobject.close()
size_checker(temp,ele,total)


Expand Down

0 comments on commit ef087d2

Please sign in to comment.