douban / dpark

Python clone of Spark, a MapReduce alike framework in Python
BSD 3-Clause "New" or "Revised" License
2.69k stars 534 forks source link

gunicorn 使用 gevent kernel 无法对file进行解析计算字符 #52

Closed bboalimoe closed 9 years ago

bboalimoe commented 9 years ago

下面的这个是一个上传文件然后算各个字母数量的小模块。我用 内核为gevent的gunicorn 启动该服务,请求时出现timeout问题。内核换为sync就木有问题~ 谢谢

@app.route('/upload', methods = ['POST'])
def upload():
    if request.method == 'POST':
        file = request.files['file']
        if file:
            filename = secure_filename(file.filename)
            file.save(os.path.join(UPLOAD_FOLDER, filename))
            f = dpark.textFile(os.path.join(UPLOAD_FOLDER, filename))
            chs = f.flatMap(lambda x: x).filter(lambda x: x in string.ascii_letters).map(lambda x: (x, 1))
            wc = chs.reduceByKey(lambda x, y: x+y).collectAsMap()
            db.LogProc.save(wc)
    return redirect('/')
windreamer commented 9 years ago

hi @bboalimoe, gevent要求组件是线程安全的,但是dpark目前不是,所以目前dpark还不能在gevent环境下运行。

bboalimoe commented 9 years ago

ok。。thanks。你们还在维护dpark么~貌似最近木有commit了~

windreamer commented 9 years ago

还在维护,但是主要功能目前没有什么未来计划了

这个issue先close了