milvus-io / pymilvus

Python SDK for Milvus.
Apache License 2.0
1.04k stars 333 forks source link

Can't run Flask+gevent with milvus connections.connect #2071

Open sealzjh opened 6 months ago

sealzjh commented 6 months ago

Is there an existing issue for this?

Describe the bug

` from flask import Flask from pymilvus import connections, Collection

app = Flask(name)

milvus_config = { "host": "127.0.0.1", "port": "19530", "cover_table": "trend_cover_cnnvec" } connections.connect( alias="default", host=milvus_config['host'], port=milvus_config['port'] ) cover_collection = Collection(milvus_config["cover_table"])

@app.route("/health") def health(): return "ok"

if name == 'main': app.run(host='0.0.0.0', port=5000) `

Expected Behavior

不能启动

gunicorn -w 1 -b 0.0.0.0:5000 main:app -k gevent

正常启动

gunicorn -w 1 -b 0.0.0.0:5000 main:app -k eventlet

Steps/Code To Reproduce behavior

run service timeout

Environment details

pymilvus==2.2.6

Anything else?

No response

xiaofan-luan commented 6 months ago

/assign @XuanYang-cn could you help to verifying that

XuanYang-cn commented 6 months ago

@sealzjh According to grpc team, you need a special patch to make grpc work with gevent, I tested it myself and it works.

Be sure to init_gevent before connect()

https://github.com/grpc/grpc/issues/4629#issuecomment-376962677

XuanYang-cn commented 6 months ago

/unassign /assign @sealzjh