Spaces:
Running
on
Zero
Running
on
Zero
derektan
commited on
Commit
·
208b0a9
1
Parent(s):
e5efc3c
Attempt to remove flickering
Browse files
app.py
CHANGED
|
@@ -213,6 +213,15 @@ def process_search_tta(
|
|
| 213 |
pngs.sort(key=lambda p: int(os.path.splitext(os.path.basename(p))[0]))
|
| 214 |
for fp in pngs:
|
| 215 |
if fp not in sent_tta:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
sent_tta.add(fp)
|
| 217 |
last_tta = fp
|
| 218 |
updated = True
|
|
@@ -221,6 +230,13 @@ def process_search_tta(
|
|
| 221 |
pngs.sort(key=lambda p: int(os.path.splitext(os.path.basename(p))[0]))
|
| 222 |
for fp in pngs:
|
| 223 |
if fp not in sent_no:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
sent_no.add(fp)
|
| 225 |
last_no = fp
|
| 226 |
updated = True
|
|
|
|
| 213 |
pngs.sort(key=lambda p: int(os.path.splitext(os.path.basename(p))[0]))
|
| 214 |
for fp in pngs:
|
| 215 |
if fp not in sent_tta:
|
| 216 |
+
# Ensure file is fully written (non-empty & readable)
|
| 217 |
+
try:
|
| 218 |
+
if os.path.getsize(fp) == 0:
|
| 219 |
+
continue
|
| 220 |
+
with open(fp, "rb") as fh:
|
| 221 |
+
fh.read(1)
|
| 222 |
+
except Exception:
|
| 223 |
+
# Skip this round; we'll retry next poll
|
| 224 |
+
continue
|
| 225 |
sent_tta.add(fp)
|
| 226 |
last_tta = fp
|
| 227 |
updated = True
|
|
|
|
| 230 |
pngs.sort(key=lambda p: int(os.path.splitext(os.path.basename(p))[0]))
|
| 231 |
for fp in pngs:
|
| 232 |
if fp not in sent_no:
|
| 233 |
+
try:
|
| 234 |
+
if os.path.getsize(fp) == 0:
|
| 235 |
+
continue
|
| 236 |
+
with open(fp, "rb") as fh:
|
| 237 |
+
fh.read(1)
|
| 238 |
+
except Exception:
|
| 239 |
+
continue
|
| 240 |
sent_no.add(fp)
|
| 241 |
last_no = fp
|
| 242 |
updated = True
|