forked from MarseyWorld/MarseyWorld
make sure all usages of subprocess have timeout duration
parent
dcf7c282a6
commit
bac356db1d
|
@ -741,7 +741,7 @@ MAX_IMAGE_AUDIO_SIZE_MB = 8
|
|||
MAX_IMAGE_AUDIO_SIZE_MB_PATRON = 16
|
||||
MAX_VIDEO_SIZE_MB = 32
|
||||
MAX_VIDEO_SIZE_MB_PATRON = 100
|
||||
MAX_IMAGE_CONVERSION_TIMEOUT = 30 # seconds
|
||||
SUBPROCESS_TIMEOUT_DURATION = 30 # seconds
|
||||
|
||||
ANTISPAM_BYPASS_IDS = set()
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ def process_audio(file, v):
|
|||
new = old + '.' + extension
|
||||
|
||||
try:
|
||||
subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-nostats", "-i", old, "-map_metadata", "-1", "-c:a", "copy", new], check=True)
|
||||
subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-nostats", "-i", old, "-map_metadata", "-1", "-c:a", "copy", new], check=True, timeout=SUBPROCESS_TIMEOUT_DURATION)
|
||||
except:
|
||||
os.remove(old)
|
||||
if os.path.isfile(new):
|
||||
|
@ -110,7 +110,7 @@ def process_audio(file, v):
|
|||
def convert_to_mp4(old, new, vid, db):
|
||||
tmp = new.replace('.mp4', '-t.mp4')
|
||||
try:
|
||||
subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-nostats", "-threads:v", "1", "-i", old, "-map_metadata", "-1", tmp], check=True, stderr=subprocess.STDOUT)
|
||||
subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-nostats", "-threads:v", "1", "-i", old, "-map_metadata", "-1", tmp], check=True, stderr=subprocess.STDOUT, timeout=SUBPROCESS_TIMEOUT_DURATION)
|
||||
except:
|
||||
os.remove(old)
|
||||
if os.path.isfile(tmp):
|
||||
|
@ -156,7 +156,7 @@ def process_video(file, v):
|
|||
gevent.spawn(convert_to_mp4, old, new, v.id, db)
|
||||
else:
|
||||
try:
|
||||
subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-nostats", "-i", old, "-map_metadata", "-1", "-c:v", "copy", "-c:a", "copy", new], check=True)
|
||||
subprocess.run(["ffmpeg", "-y", "-loglevel", "warning", "-nostats", "-i", old, "-map_metadata", "-1", "-c:v", "copy", "-c:a", "copy", new], check=True, timeout=SUBPROCESS_TIMEOUT_DURATION)
|
||||
except:
|
||||
os.remove(old)
|
||||
if os.path.isfile(new):
|
||||
|
@ -212,7 +212,7 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
|
|||
|
||||
params.append(filename)
|
||||
try:
|
||||
subprocess.run(params, timeout=MAX_IMAGE_CONVERSION_TIMEOUT)
|
||||
subprocess.run(params, timeout=SUBPROCESS_TIMEOUT_DURATION)
|
||||
except:
|
||||
os.remove(filename)
|
||||
if has_request:
|
||||
|
|
|
@ -655,7 +655,7 @@ def submit_post(v:User, sub=None):
|
|||
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||
subprocess.run(['ffmpeg', '-y', '-loglevel', 'warning',
|
||||
'-i', p.url, '-vf', "scale='iw':-2",
|
||||
'-q:v', '3', '-frames:v', '1', name], check=True)
|
||||
'-q:v', '3', '-frames:v', '1', name], check=True, timeout=SUBPROCESS_TIMEOUT_DURATION)
|
||||
p.posterurl = name
|
||||
|
||||
name2 = name.replace('.webp', 'r.webp')
|
||||
|
|
Loading…
Reference in New Issue