mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-12-04 13:50:05 -05:00
Android job cancel
This commit is contained in:
parent
d3874ddedb
commit
fa683e6c21
1 changed files with 12 additions and 4 deletions
|
|
@ -347,21 +347,23 @@ def generate_stamped_key(material, stamp_cost):
|
||||||
def cancel_work(message_id):
|
def cancel_work(message_id):
|
||||||
if RNS.vendor.platformutils.is_windows() or RNS.vendor.platformutils.is_darwin():
|
if RNS.vendor.platformutils.is_windows() or RNS.vendor.platformutils.is_darwin():
|
||||||
try:
|
try:
|
||||||
if message_id in active_jobs:
|
if message_id in active_jobs: active_jobs[message_id] = True
|
||||||
active_jobs[message_id] = True
|
else: return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
|
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
|
||||||
RNS.trace_exception(e)
|
RNS.trace_exception(e)
|
||||||
|
return False
|
||||||
|
|
||||||
elif RNS.vendor.platformutils.is_android():
|
elif RNS.vendor.platformutils.is_android():
|
||||||
try:
|
try:
|
||||||
if message_id in active_jobs:
|
if message_id in active_jobs: active_jobs[message_id] = True
|
||||||
active_jobs[message_id] = True
|
else: return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
|
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
|
||||||
RNS.trace_exception(e)
|
RNS.trace_exception(e)
|
||||||
|
return False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|
@ -374,10 +376,14 @@ def cancel_work(message_id):
|
||||||
stop_event.set()
|
stop_event.set()
|
||||||
result_queue.put(None)
|
result_queue.put(None)
|
||||||
active_jobs.pop(message_id)
|
active_jobs.pop(message_id)
|
||||||
|
else: return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
|
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
|
||||||
RNS.trace_exception(e)
|
RNS.trace_exception(e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def job_simple(stamp_cost, workblock, message_id, size, mode=MODE_STAMP):
|
def job_simple(stamp_cost, workblock, message_id, size, mode=MODE_STAMP):
|
||||||
# A simple, single-process stamp generator.
|
# A simple, single-process stamp generator.
|
||||||
|
|
@ -710,6 +716,8 @@ def job_android_persistent(stamp_cost, workblock, message_id, size, mode=MODE_ST
|
||||||
RNS.log(f"Stamp ({cost_from_fp(stamp_cost)}) generation running, {RNS.prettyshorttime(elapsed)} elapsed", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
RNS.log(f"Stamp ({cost_from_fp(stamp_cost)}) generation running, {RNS.prettyshorttime(elapsed)} elapsed", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||||
last_progress = time.time()
|
last_progress = time.time()
|
||||||
|
|
||||||
|
if message_id in active_jobs and active_jobs[message_id] == True: stop_flag[0] = 1
|
||||||
|
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue