皮蒙戈 + gevent:扔给我一根香蕉然后只扔monkey_patch?
这里快速地需要比我现在更多的 pymongo 领域专业知识:
pymongo 驱动程序的“正确”部分是用 python 编写的,以便我调用 gevent Monkey_patch() 并成功改变 pymongo 在 gevent“异步”内的读/写上的阻塞行为“小绿叶?
如果这需要在 gevent 和 pymongo 上做更多的工作——但这是可行的——我非常愿意投入时间,只要我能得到一些关于 irc 的指导。
谢谢!
注意:小规模的 mongo 写入并不是一个大问题,因为我们只是在解锁之前对写入“请求”进行排队。但是在与 fiorix 谈论他扭曲的异步 mongo 驱动程序 (https://github.com/fiorix/mongo-async-python-driver) 时,即使 mongo 的快速写入(请求)也会在大规模异步应用程序中导致问题。 (当然,非阻塞读取可能从一开始就会引起问题!)
Quickie here that needs more domain expertise on pymongo than I have right now:
Are the "right" parts of the pymongo driver written in python for me to call gevent monkey_patch() and successfully alter pymongo's blocking behavior on r/w within gevent "asynchronous" greenlets?
If this will require a little more leg work on gevent and pymongo -- but it is feasible -- I would be more than willing to put in the time as long as i can get a little guidance over irc.
Thanks!
Note: At small scale mongo writes are not a big problem because we are just queuing a write "request" before unblocking. BUT talking to fiorix about his twisted async mongo driver (https://github.com/fiorix/mongo-async-python-driver), even mongo's quick write (requests) can cause problems in asyncronous applications at scale. (And of course, non-blocking reads could cause problems from the start!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已将 PyMongo 与 Gevent 一起使用,这里有一些您需要注意的事项:
Connection
本身就有一个池!Connection
中使用了线程局部变量,仅修补套接字是不够的。end_request
将连接返回到池中。你的问题的答案是继续,PyMongo 与 Gevent 配合得很好。
I have used PyMongo with Gevent and here are a few things you need to watch out for:
pymongo.Connection
object, preferrably as a global or module-level variable. This is important becauseConnection
has within itself a pool!Connection
, patching socket alone is not enough.end_request
to return the connection to the pool.The answer to your question is go ahead, PyMongo works just fine with Gevent.
初步检查时,它似乎没有在 c 代码中执行任何套接字操作,因此应该没问题(阻塞操作应该只阻塞绿色线程)。
On initial inspection it doesn't appear to do any socket operations in the c code so it should be fine (blocking ops should just block the green thread).