Permalink
Browse files

Moving mailing out to a separate thread so it doesn't lock up the mai…

…n loop

in an (eternal) wait.

Cleaning away old .keep file
  • Loading branch information...
morphex committed Sep 24, 2018
1 parent a02dbc0 commit 146f1fe88511f943585541b7b3192590ce154b91
Showing with 20 additions and 7 deletions.
  1. +20 −7 surveil.py
  2. 0 surveil/.keep
View
@@ -8,6 +8,10 @@
TMPFS_SIZE_MB = 50
TMPFS_SIZE = 1024 * 1024 * TMPFS_SIZE_MB
# Percentage of temporary storage used, before videos are moved to
# permanent storage
TMPFS_THRESHOLD = 75
SURVEIL_DIR = 'surveil'
# Seconds to sleep between each picture taken
@@ -162,6 +166,22 @@ def setup_video():
else:
return False
def mailer():
while 1:
for video in glob.glob("video??????"):
try:
os.stat(video + "/done.txt")
message_video(video)
break
except FileNotFoundError:
pass
time.sleep(5) # So we don't spam the system
# Start mailer
import _thread
_thread.start_new_thread(mailer, ())
# Main loop
while 1:
_time = time.time()
filename = '%08i.jpg' % _INDEX
@@ -186,13 +206,6 @@ def setup_video():
time.sleep(1)
else:
break
for video in glob.glob("video??????"):
try:
os.stat(video + "/done.txt")
message_video(video)
break
except FileNotFoundError:
pass
#message(path)
setup_video()
while time.time() < (_time + SLEEP_SECONDS):
View
No changes.

0 comments on commit 146f1fe

Please sign in to comment.