Commit 6bbfb683 by Máhonfai Bálint

Check abort only if percentage changed

This avoids checking abort too frequently.
parent 899f5736
...@@ -278,9 +278,9 @@ class Disk(object): ...@@ -278,9 +278,9 @@ class Disk(object):
f.write(chunk) f.write(chunk)
current_size = f.tell() current_size = f.tell()
new_percent = current_size * 100 / clen new_percent = current_size * 100 / clen
if task.is_aborted():
raise AbortException()
if new_percent > percent: if new_percent > percent:
if task.is_aborted():
raise AbortException()
percent = new_percent percent = new_percent
task.update_state( task.update_state(
task_id=parent_id, task_id=parent_id,
...@@ -337,9 +337,9 @@ class Disk(object): ...@@ -337,9 +337,9 @@ class Disk(object):
def update_state(monitor): def update_state(monitor):
new_percent = monitor.bytes_read * 100 / size new_percent = monitor.bytes_read * 100 / size
if task.is_aborted():
raise AbortException()
if new_percent > percent[0]: if new_percent > percent[0]:
if task.is_aborted():
raise AbortException()
percent[0] = new_percent percent[0] = new_percent
task.update_state( task.update_state(
task_id=parent_id, task_id=parent_id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment