pychrome
pychrome copied to clipboard
It seems the doc is wrong about method: tab.wait(5)
In the document https://fate0.github.io/pychrome/#getting-started there is sample code
# start the tab
tab.start()
tab.Page.navigate(url="https://github.com/fate0/pychrome", _timeout=5)
# wait for loading
tab.wait(5)
# stop the tab (stop handle events and stop recv message from chrome)
tab.stop()
But when I look inside the pychrome code. wait is defined like this
def wait(self, timeout=None):
if not self._started:
raise RuntimeException("Tab is not running")
if timeout:
return self._stopped.wait(timeout)
self._recv_th.join()
self._handle_event_th.join()
return True
The wait should be described as wait for thread stopped, So I think the right document should be
# start the tab
tab.start()
tab.Page.navigate(url="https://github.com/fate0/pychrome", _timeout=5)
# stop the tab (stop handle events and stop recv message from chrome)
tab.stop()
# wait for thread handle stopped
tab.wait(5)
tab.wait()是在等待线程事件返回内部信号,从外部看是在等待chrome的进程加载页面,并返回结果。