QNetworkAccessManager
can do requests asynchronously, and time.sleep(secs)
can suspend the execution for the given number of seconds. I was confused by the code below. Is t2
here always greater than 10 seconds?
Without using time.sleep(secs)
in the code here, the finished slot getWebPageSRC
was called in fixed amount of time, roughly about 3 seconds.
I have tested this now a couple of times and found that t2 is always greater than 10 seconds. Can anyone explain why?
de myMethod(self):
...
reply.finished.connect(self.getWebPageSRC)
self.t=time.clock()
time.sleep(10)
def getWebPageSRC(self):
t2=time.clock()-self.t
print(t2)
P.S. since QNAM doing its work asynchronously, I think it works in another thread ,thus has its own event loop , so does time.sleep(secs) suspend all the Qt event loop of all threads or just the event loop of the thread it within ? Does sleeping in main thread suspend all other threads ' event loop ?