|
@ -24,6 +24,9 @@ from secrets import token_urlsafe |
|
|
from time import sleep |
|
|
from time import sleep |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timing = .3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def unlock(inbox): |
|
|
def unlock(inbox): |
|
|
"clear the inbox from lockfile" |
|
|
"clear the inbox from lockfile" |
|
|
|
|
|
|
|
@ -46,14 +49,14 @@ class Lock: |
|
|
def __enter__(self): |
|
|
def __enter__(self): |
|
|
lockfile = self.inbox / "lock" |
|
|
lockfile = self.inbox / "lock" |
|
|
while lockfile.is_file(): |
|
|
while lockfile.is_file(): |
|
|
sleep(1) |
|
|
sleep(timing) |
|
|
lockfile.touch() |
|
|
lockfile.touch() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def send(inbox, msg, marker): |
|
|
def send(inbox, msg, marker): |
|
|
"send msg to inbox in MIME format" |
|
|
"send msg to inbox in MIME format" |
|
|
|
|
|
|
|
|
sleep(1) |
|
|
sleep(timing) |
|
|
with Lock(inbox): |
|
|
with Lock(inbox): |
|
|
name = marker + "_" + token_urlsafe(16) + ".eml" |
|
|
name = marker + "_" + token_urlsafe(16) + ".eml" |
|
|
with open(inbox / name, "wb") as f: |
|
|
with open(inbox / name, "wb") as f: |
|
@ -94,7 +97,7 @@ def recv_all(inbox, marker): |
|
|
os.utime(str(inbox / marker), (newest, newest)) |
|
|
os.utime(str(inbox / marker), (newest, newest)) |
|
|
|
|
|
|
|
|
if not r: |
|
|
if not r: |
|
|
sleep(1) |
|
|
sleep(timing) |
|
|
|
|
|
|
|
|
return r |
|
|
return r |
|
|
|
|
|
|
|
|