在Ubuntu 11.04 XVFB运行错误 [英] xvfb run error in ubuntu 11.04

查看:180
本文介绍了在Ubuntu 11.04 XVFB运行错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是抓取使用无头的WebKit(PyQt4.QtWebkit)在python谷歌的搜索结果。 使用PyQt4.I应该执行该脚本亚马逊ec2.So该模块在地上爬来爬去,结果很好,我应该使用的的Xvfb (NO x的在EC2服务器)。

My task is crawling the google search results using headless webkit(PyQt4.QtWebkit) in python. The module was crawling the results fine using PyQt4.I should have to execute this script in amazon ec2.So,I should have to use Xvfb (no x server in ec2).

同时我模块在一个loop.So要执行,这是工作的罚款对一些iterations.After一些循环模块运行到XVFB运行:错误:Xvfb来未能启动

At the same time my module has to be executed in a loop.So, It was working fine for some iterations.After some looping module runs into "xvfb-run: error: Xvfb failed to start"

这是应该如何解决?

这是我的循环:

for i in range(10):
    try:
        query_dict["start"] = i * 10
        url = base_url + ue(query_dict)
        flag = True
        while flag:
            parsed_dict = main(url)
            time.sleep(8.4)
            flag = False
    except:
        pass

主(URL):

main(url) :

def main(url):
    cmd = "xvfb-run python /home/shan/temp/hg_intcen/lib/webpage_scrapper.py"+" "+str(url)
    print "Cmd EXE:"+ cmd
    proc = subprocess.Popen(cmd,shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE)
    proc.wait()
    sys.stdout.flush()
    result = proc.stdout.readlines()
    print "crawled: ",result[1]
    return result

webpage_scrapper将获取使用PyQt4中所有的HTML结果。 如何避免XVFB失败的循环?

webpage_scrapper will fetch all the html results using pyqt4. How to avoid the xvfb failing for looping?

推荐答案

您需要添加 - 自动SERVERNUM 参数 XVFB运行。否则,它会尝试产卵的Xvfb 在同一显示器上(默认为 99 ),如果你将失败已经有一个运行。

You need to add --auto-servernum parameter for xvfb-run. Otherwise, it tries to spawn Xvfb on the same display (by default :99), which will fail if you already have one running.

这篇关于在Ubuntu 11.04 XVFB运行错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆