Addon Manager: Improve startup speed

This commit is contained in:
Chris Hennes
2022-01-26 18:40:41 -06:00
parent a770c1c1b9
commit 8809ed4253
4 changed files with 42 additions and 29 deletions

View File

@@ -146,6 +146,9 @@ if HAVE_QTNETWORK:
self.synchronous_complete: Dict[int, bool] = {}
self.synchronous_result_data: Dict[int, QtCore.QByteArray] = {}
# Make sure we exit nicely on quit
QtCore.QCoreApplication.instance().aboutToQuit.connect(self.aboutToQuit)
def run(self):
"""Do not call directly: use start() to begin the event loop on a new thread."""
@@ -257,6 +260,10 @@ if HAVE_QTNETWORK:
pass
QtCore.QCoreApplication.processEvents()
def aboutToQuit(self):
self.requestInterruption()
def submit_unmonitored_get(self, url: str) -> int:
"""Adds this request to the queue, and returns an index that can be used by calling code
in conjunction with the completed() signal to handle the results of the call. All data is
@@ -506,14 +513,18 @@ else: # HAVE_QTNETWORK is false:
pass # Nothing to do
AM_NETWORK_MANAGER = NetworkManager()
AM_NETWORK_MANAGER.start()
def InitializeNetworkManager():
global AM_NETWORK_MANAGER
if AM_NETWORK_MANAGER is None:
AM_NETWORK_MANAGER = NetworkManager()
AM_NETWORK_MANAGER.start()
if __name__ == "__main__":
app = QtCore.QCoreApplication()
InitializeNetworkManager()
count = 0
# For testing, create several network requests and send them off in quick succession: