mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +02:00
upload_file_async carried a flat 600s wall-clock deadline and ran the transfer via asyncio.wait_for(run_in_executor(...)). wait_for cancels the future, not the executor thread. A 96 MB 3MF to an A1 over WiFi sustains ~75 KB/s and needs ~20 minutes, so the await gave up at ~70 MB, returned False, and with_ftp_retry started a second STOR of the same file onto the same printer while the first was still streaming. The reporter filmed two transfers of one job climbing in parallel at 2% and 72%; the print never landed and the printer read as having a flaky network. The deadline is now derived from the file size against a 25 KB/s floor, so a slow-but-healthy transfer can finish — a link that has actually died is caught within socket_timeout by the blocking sendall, which is what should be detecting failure. A deadline expiry now stops the transfer for real: the worker is signalled, raises UploadCancelled from its progress callback, and upload_file's existing cancel path breaks the send loop and deletes the partial file. with_ftp_retry never retries that, and a per-printer lock makes overlapping uploads impossible however they were triggered.