简体   繁体   English

防止在eventlet中切换greenthread

[英]Prevent greenthread switch in eventlet

I have a Django/Tastypie app where I've monkey patched everything with eventlet. 我有一个Django / Tastypie应用,在这里我用eventlet修补了所有事情。

I analysed performance during load tests while using both sync and eventlet worker clasees for gunicorn. 我在负载测试期间分析了性能,同时使用了同步和事件let工人手风琴。 I tested against sync workers to eliminate the effects of waiting for other greenthreads to switch back, and I found that the memcached calls in my throttling code only take about 1ms on their own. 我对同步工作者进行了测试,以消除等待其他绿线程切换回去的影响,我发现节流代码中的memcached调用本身仅花费约1ms的时间。 Rather than switch to another greenthread while waiting for this 1ms response, I'd rather just block at this one point. 与其在等待1ms响应时切换到另一个greenthread,不如在这一点上进行阻塞。 Is there some way to tell eventlet to not switch to another greenthread? 有什么方法可以告诉eventlet不要切换到另一个greenthread? Maybe a context manager or something? 也许是上下文管理器之类的?

There is no such context manager, though you are welcome to contribute one. 没有这样的上下文管理器,尽管欢迎您贡献一个。

You have monkey patched everything, but you do not want to monkey patch socket in memcache client. 您已经猴子修补了所有内容,但是不想在内存缓存客户端中猴子修补socket Your options: 您的选择:

  • monkey patch everything but socket , then patcher.import_patched particular modules. patcher.import_patched修补了socket所有东西,然后patcher.import_patched特定模块。 This is going to be very hard with Django/Tastypie. 对于Django / Tastypie,这将非常困难。
  • modify your memcache client to use eventlet.patcher.original('socket') 修改您的内存缓存客户端以使用eventlet.patcher.original('socket')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM