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

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

问题描述

我的任务是在 python 中使用 headless webkit(PyQt4.QtWebkit) 抓取 google 搜索结果.该模块使用 PyQt4 抓取结果很好.我应该必须在亚马逊 ec2 中执行这个脚本.所以,我应该使用 Xvfb(ec2 中没有 x 服务器).

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).

同时我的模块必须在循环中执行.所以,它在一些迭代中工作正常.在一些循环模块运行到xvfb-run:错误:Xvfb无法启动"后/strong>

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

主(网址):

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?

推荐答案

您需要为 xvfb-run 添加--auto-servernum 参数.否则,它会尝试在同一显示器上生成 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.

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

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