Use a list for pending requests
This commit is contained in:
parent
5ab9755ac4
commit
3f37c0bb0b
@ -50,7 +50,7 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
def __init__(self, cookiejar=None, parent=None):
|
def __init__(self, cookiejar=None, parent=None):
|
||||||
log.init.debug("Initializing NetworkManager")
|
log.init.debug("Initializing NetworkManager")
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._requests = {}
|
self._requests = []
|
||||||
self._scheme_handlers = {
|
self._scheme_handlers = {
|
||||||
'qute': QuteSchemeHandler(),
|
'qute': QuteSchemeHandler(),
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
|
|
||||||
def abort_requests(self):
|
def abort_requests(self):
|
||||||
"""Abort all running requests."""
|
"""Abort all running requests."""
|
||||||
for request in self._requests.values():
|
for request in self._requests:
|
||||||
request.abort()
|
request.abort()
|
||||||
|
|
||||||
@pyqtSlot('QNetworkReply*', 'QList<QSslError>')
|
@pyqtSlot('QNetworkReply*', 'QList<QSslError>')
|
||||||
@ -146,6 +146,6 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
req.setRawHeader('Accept-Language'.encode('ascii'),
|
req.setRawHeader('Accept-Language'.encode('ascii'),
|
||||||
accept_language.encode('ascii'))
|
accept_language.encode('ascii'))
|
||||||
reply = super().createRequest(op, req, outgoing_data)
|
reply = super().createRequest(op, req, outgoing_data)
|
||||||
self._requests[id(reply)] = reply
|
self._requests.append(reply)
|
||||||
reply.destroyed.connect(lambda obj: self._requests.pop(id(obj)))
|
reply.destroyed.connect(lambda obj: self._requests.remove(obj))
|
||||||
return reply
|
return reply
|
||||||
|
Loading…
Reference in New Issue
Block a user