【发布时间】:2015-10-05 22:15:39
【问题描述】:
我有一个 URL 列表。我想每 10 秒异步获取他们的内容。
urls = [
'http://www.python.org',
'http://stackoverflow.com',
'http://www.twistedmatrix.com',
'http://www.google.com',
'http://launchpad.net',
'http://github.com',
'http://bitbucket.org',
]
waiting = [client.getPage(url) for url in urls]
defer.gatherResults(waiting).addCallback(saveResults)
reactor.run()
我该怎么做?此代码允许我只获取一次 urls 内容。再次调用它会抛出error.ReactorNotRestartable()
谢谢:)
【问题讨论】:
-
本例中没有线程。你打算加入一些吗?
标签: multithreading twisted reactor