Bug report #12243

QgsNetworkAccessManager time out error

Added by Kelly Thomas about 9 years ago. Updated over 7 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Network
Affected QGIS version:2.6.1 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:20428

Description

When using QgsNetworkAccessManager.createRequest() to initiate a download I find that despite completing successfully, and providing the correct data, a network time out error is displayed on the GUI via the Message Bar and the Message Log.

It can be reproduced by pasting the following into the Python Console:

from datetime import datetime
from PyQt4.QtCore import SIGNAL, QUrl
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest

def request_download():
    global reply
    manager = QgsNetworkAccessManager.instance()
    url = QUrl("http://www.example.net")
    request = QNetworkRequest(url)
    print "Download start time: {}".format(datetime.now())
    reply = manager.createRequest(QNetworkAccessManager.GetOperation, request)
    reply.connect(reply, SIGNAL("finished()"), handle_download)

def handle_download():
    global reply
    print "Download finish time: {}".format(datetime.now())
    print "Finished: {}".format(reply.isFinished())
    print "Bytes received: {}".format(len(reply.readAll()))

request_download()

# python console:
#   Download start time: 2015-02-23 15:24:39.887000
#   Download finish time: 2015-02-23 15:24:41.077000
#   Finished: True
#   Bytes received: 1270
# 
# message log:
#   2015-02-23T15:25:01    1    Network request http://www.example.com timed out

Discussion of this issue is available on GIS.SE:
http://gis.stackexchange.com/questions/136369/download-file-from-network-using-pyqgis-2-x/

Associated revisions

Revision ace9d2b0
Added by Alessandro Pasotti over 7 years ago

Stop the timer when the reply finish

This should fix a few reported and unreported issues
with false positive timeout errors.

Fixes: #12243

Revision a064c0a1
Added by Alessandro Pasotti over 7 years ago

Stop the timer when the reply finish

This should fix a few reported and unreported issues
with false positive timeout errors.

Fixes: #12243

(cherry-picked from ace9d2b0f661849106f0448189cb233710754f12)

Revision c2db70b3
Added by Alessandro Pasotti over 7 years ago

Stop the timer when the reply finish

This should fix a few reported and unreported issues
with false positive timeout errors.

Fixes: #12243

(cherry-picked from ace9d2b0f661849106f0448189cb233710754f12)

History

#1 Updated by Anonymous over 7 years ago

  • Status changed from Open to Closed

Fixed in changeset commit:"8251c30ae31560f308414f217e1e787e81f55232".

Also available in: Atom PDF