diff options
author | Ghostkeeper <rubend@tutanota.com> | 2020-08-25 13:23:58 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2020-08-25 13:23:58 +0300 |
commit | d021fd10fb1b9fcb447963f5ac962b6dc79c2e23 (patch) | |
tree | e29976ba3ab474f2823b2b98b191c67f11187784 | |
parent | afb29724ffcbd5c0e7cfaa75066dc899e3c4efd1 (diff) |
Don't crash when trying to upload two jobs at the same time
This will now result in a job being put in the queue but not automatically printing, but there is at least a workaround for that.
Fixes Sentry issue CURA-14A.
-rw-r--r-- | plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 3742806716..3b73e54b25 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -1,5 +1,6 @@ -# Copyright (c) 2019 Ultimaker B.V. +# Copyright (c) 2020 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. + from time import time import os from typing import List, Optional, cast @@ -228,10 +229,16 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): self._onUploadError) def _onPrintJobUploaded(self) -> None: - """Requests the print to be sent to the printer when we finished uploading the mesh.""" + """ + Requests the print to be sent to the printer when we finished uploading + the mesh. + """ self._progress.update(100) print_job = cast(CloudPrintJobResponse, self._uploaded_print_job) + if not print_job: # It's possible that another print job is requested in the meanwhile, which then fails to upload with an error, which sets self._uploaded_print_job to `None`. + # TODO: Maybe _onUploadError shouldn't set the _uploaded_print_job to None or we need to prevent such asynchronous cases. + return # Prevent a crash. self._api.requestPrint(self.key, print_job.job_id, self._onPrintUploadCompleted) def _onPrintUploadCompleted(self, response: CloudPrintResponse) -> None: |