eventlet time sleep

Monkeypatching the Standard Library

The other way of greening an application is simply to monkeypatch the standard library. This has the disadvantage of appearing quite magical, but the advantage of avoiding the late-binding problem.

eventlet.patcher. monkey_patch ( os=None, select=None, socket=None, thread=None, time=None, psycopg=None )

This function monkeypatches the key system modules by replacing their key elements with green equivalents. If no arguments are specified, everything is patched:

import eventlet
eventlet.monkey_patch()

The keyword arguments afford some control over which modules are patched, in case that’s important. Most patch the single module of the same name (e.g. time=True means that the time module is patched [time.sleep is patched by eventlet.sleep]). The exceptions to this rule are socket, which also patches the ssl module if present; and thread, which patches thread, threading, and Queue.

Here’s an example of using monkey_patch to patch only a few modules:

import eventlet
eventlet.monkey_patch(socket=True, select=True)
posted on 2010-10-03 10:36  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2010/10/03/1841549.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值