stackless python如何给tasklet加锁
2014-08-13 10:08
309 查看
stacless本身并不支持锁机制,但是可以通过channel的send和receive方法来模拟,下面是一个简单的锁。
import stackless class TaskLock(stackless.channel): def __init__(self): self._islock = False self.tasklet = None def lock(self): if self._islock == True : self.receive() self.tasklet = stackless.getcurrent() self._islock = True def unlock(self): self.tasklet = None self._islock = False if self.balance < 0 : self.send(0) lock = TaskLock() lock.lock() ... lock.unlock()
相关文章推荐
- Gamebryo2.5 和 stackless Python的联合调试配置
- stackless python
- 高性能python编程之协程(stackless)
- Stackless Python并发式编程介绍
- install stackless python on ubuntu
- python如何使用 os.path.exists()--Learning from stackoverflow
- UBUNTU10.04安装stackless python运行高性能服务器
- Stackless Python安装详细操作手册
- stackless python改prime number一则
- Stackless Python 并发式编程介绍
- UBUNTU10.04安装stackless python运行高性能服务器
- Python(Stackless) + MongoDB Apache 日志(2G)分析
- 对stackless python很失望
- Stackless Python
- python如何使用 os.path.exists()--Learning from stackoverflow 分类: python 2015-04-23 20:48 139人阅读 评论(0) 收藏
- Stackless Python并发式编程介绍
- stackless python hackysack问题续
- Stackless Python安装详细操作手册
- 编译 stackless python
- stackless python的疑问