Skip to content

Commit

Permalink
Download manager abort transter on stop_loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ondratu committed Mar 13, 2024
1 parent 4220fe6 commit 6de0ca0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
ChangeLog
=========
0.8.0alpha1
0.8.0alpha2
* Report read timeouts differently
* Initial support for the new connect MMU API
* Add new SL types
* Download manager abort transter on stop_loop

0.7.1 (2023-10-09)
* Attribute ro renamed to read_only
Expand Down
2 changes: 1 addition & 1 deletion prusa/connect/printer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)
from .util import RetryingSession, get_timestamp

__version__ = "0.8.0alpha1"
__version__ = "0.8.0alpha2"
__date__ = "6 Dec 2023" # version date
__copyright__ = "(c) 2023 Prusa 3D"
__author_name__ = "Prusa Link Developers"
Expand Down
2 changes: 2 additions & 0 deletions prusa/connect/printer/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ def download(self):
for data in res.iter_content(chunk_size=self.buffer_size):
if self.transfer.stop_ts > 0:
raise TransferStoppedError("Transfer was stopped")
if not self._running_loop:
raise TransferAbortedError("Transfer was aborted")
f.write(data)
if self.throttle:
time.sleep(self.throttle)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def download_mgr(printer):


def run_test_loop(download_mgr, timeout=.1, unset_stop=False):

def fullstop():
download_mgr.transfer.stop()
if unset_stop:
download_mgr.transfer.stop()
download_mgr.transfer.stop_ts = 0
download_mgr._running_loop = False

Expand Down Expand Up @@ -115,6 +116,7 @@ def test_download_stop(gcode, download_mgr):
transfer = download_mgr.transfer
download_mgr.buffer_size = 1
run_test_loop(download_mgr)
download_mgr.transfer.stop()

assert transfer.time_remaining() == 0

Expand Down

0 comments on commit 6de0ca0

Please sign in to comment.