提供生成自移除对象
expiring_object的Python项目详细描述
#即将过期的对象
![[pypi](https://pypi.python.org/project/expiring_object)](https://img.shields.io/pypi/v/expiring_object.svg)
![许可证](https://img.shields.io/pypi/l/expiring_object.svg)
![状态](https://img.shields.io/pypi/status/expiring_object.svg)
![Python版本](https://img.shields.io/pypi/pyversions/expiring_object.svg)
![下载](https://img.shields.io/pypi/dw/expiring_object.svg)
此模块提供了一种简单的方法来构建自移除对象
\obj=对象工厂(stub(),dp)传递要自移除的对象,并由Dispatcher实例执行操作。sleep(10)
=dispatcher(10)
dp.start()
some_ref=stub()
some_ref=proxy(some_ref)对对象的弱引用
dp.add(some_ref)
必须删除指向此对象的链接
以另一种方式,只有处理程序(如果指定)才会调用
del some_ref
执行
time.sleep(10)
对象是自移除的
dp.stop()
del弱引用;此代理对象已经不需要
````
当生存期过期时,它将调用(然后删除项):
``python
类存根:
def_handler(self):
print('deleting`stub`')
dp.add(stub())
```
>;注意:您应该提醒此对象不能有其他强引用
![[pypi](https://pypi.python.org/project/expiring_object)](https://img.shields.io/pypi/v/expiring_object.svg)
![许可证](https://img.shields.io/pypi/l/expiring_object.svg)
![状态](https://img.shields.io/pypi/status/expiring_object.svg)
![Python版本](https://img.shields.io/pypi/pyversions/expiring_object.svg)
![下载](https://img.shields.io/pypi/dw/expiring_object.svg)
此模块提供了一种简单的方法来构建自移除对象
\obj=对象工厂(stub(),dp)传递要自移除的对象,并由Dispatcher实例执行操作。sleep(10)
=dispatcher(10)
dp.start()
some_ref=stub()
some_ref=proxy(some_ref)对对象的弱引用
dp.add(some_ref)
必须删除指向此对象的链接
以另一种方式,只有处理程序(如果指定)才会调用
del some_ref
执行
time.sleep(10)
对象是自移除的
dp.stop()
del弱引用;此代理对象已经不需要
````
当生存期过期时,它将调用(然后删除项):
``python
类存根:
def_handler(self):
print('deleting`stub`')
dp.add(stub())
```
>;注意:您应该提醒此对象不能有其他强引用