mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 16:27:51 -06:00
Throttle how often the local cluster updates
This puts it in line with how often the cloud does it Might contribute to #11608
This commit is contained in:
parent
89fbac74f9
commit
023046370a
1 changed files with 6 additions and 0 deletions
|
@ -3,6 +3,8 @@
|
||||||
import os
|
import os
|
||||||
from typing import Optional, Dict, List, Callable, Any
|
from typing import Optional, Dict, List, Callable, Any
|
||||||
|
|
||||||
|
from time import time
|
||||||
|
|
||||||
from PyQt6.QtGui import QDesktopServices
|
from PyQt6.QtGui import QDesktopServices
|
||||||
from PyQt6.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QObject
|
from PyQt6.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QObject
|
||||||
from PyQt6.QtNetwork import QNetworkReply
|
from PyQt6.QtNetwork import QNetworkReply
|
||||||
|
@ -32,6 +34,8 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
activeCameraUrlChanged = pyqtSignal()
|
activeCameraUrlChanged = pyqtSignal()
|
||||||
|
|
||||||
|
CHECK_CLUSTER_INTERVAL = 10.0 # seconds
|
||||||
|
|
||||||
def __init__(self, device_id: str, address: str, properties: Dict[bytes, bytes], parent=None) -> None:
|
def __init__(self, device_id: str, address: str, properties: Dict[bytes, bytes], parent=None) -> None:
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
|
@ -107,6 +111,8 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
def _update(self) -> None:
|
def _update(self) -> None:
|
||||||
super()._update()
|
super()._update()
|
||||||
|
if time() - self._time_of_last_request < self.CHECK_CLUSTER_INTERVAL:
|
||||||
|
return # avoid calling the cluster too often
|
||||||
self._getApiClient().getPrinters(self._updatePrinters)
|
self._getApiClient().getPrinters(self._updatePrinters)
|
||||||
self._getApiClient().getPrintJobs(self._updatePrintJobs)
|
self._getApiClient().getPrintJobs(self._updatePrintJobs)
|
||||||
self._updatePrintJobPreviewImages()
|
self._updatePrintJobPreviewImages()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue