mirror of
https://github.com/flibusta-apps/fb2converter_server.git
synced 2025-12-06 06:55:36 +01:00
Fix bugs
This commit is contained in:
16
app/main.py
16
app/main.py
@@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
from typing import AsyncIterator
|
||||
import uuid
|
||||
@@ -96,16 +96,12 @@ app.include_router(router)
|
||||
|
||||
@app.on_event("startup")
|
||||
@repeat_every(seconds=60, raise_exceptions=True)
|
||||
async def remove_temp_files():
|
||||
def _foo():
|
||||
def remove_temp_files():
|
||||
current_time = time.time()
|
||||
|
||||
for f in os.listdir("/tmp/"):
|
||||
creation_time = os.path.getctime(f)
|
||||
target_path = f"/tmp/{f}"
|
||||
|
||||
creation_time = os.path.getctime(target_path)
|
||||
if (current_time - creation_time) // 3600 >= 3:
|
||||
os.unlink(f)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
with ThreadPoolExecutor(1) as executor:
|
||||
await loop.run_in_executor(executor, _foo)
|
||||
os.unlink(target_path)
|
||||
|
||||
Reference in New Issue
Block a user