Hopefully fixed lockup bug.
This commit is contained in:
30
util.py
30
util.py
@@ -312,15 +312,29 @@ def get_media_duration(path):
|
||||
command = ("ffprobe", "-v", "quiet", "-show_entries", "format=duration",
|
||||
"-of", "default=noprint_wrappers=1:nokey=1", path)
|
||||
process = sp.Popen(command, stdout=sp.PIPE, stderr=sp.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
try:
|
||||
if not stderr:
|
||||
return float(stdout)
|
||||
else:
|
||||
stdout, stderr = process.communicate(timeout=10) # Add timeout to prevent hanging
|
||||
|
||||
try:
|
||||
if not stderr:
|
||||
return float(stdout)
|
||||
else:
|
||||
return 0
|
||||
except ValueError:
|
||||
return 0
|
||||
except ValueError:
|
||||
except sp.TimeoutExpired:
|
||||
process.kill()
|
||||
process.wait()
|
||||
return 0
|
||||
finally:
|
||||
# Ensure process is properly cleaned up
|
||||
if process.poll() is None:
|
||||
process.terminate()
|
||||
try:
|
||||
process.wait(timeout=2)
|
||||
except sp.TimeoutExpired:
|
||||
process.kill()
|
||||
process.wait()
|
||||
|
||||
|
||||
def parse_time(human):
|
||||
@@ -405,9 +419,9 @@ def get_snapshot_version():
|
||||
ver = "unknown"
|
||||
if os.path.exists(os.path.join(root_dir, ".git")):
|
||||
try:
|
||||
ret = subprocess.check_output(["git", "describe", "--tags"]).strip()
|
||||
ret = subprocess.check_output(["git", "describe", "--tags"], timeout=5).strip()
|
||||
ver = ret.decode("utf-8")
|
||||
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||
except (FileNotFoundError, subprocess.CalledProcessError, subprocess.TimeoutExpired):
|
||||
try:
|
||||
with open(os.path.join(root_dir, ".git/refs/heads/master")) as f:
|
||||
ver = "g" + f.read()[:7]
|
||||
|
Reference in New Issue
Block a user