[英]Python not able to pickle ZabbixAPI class instance
I'm not able to pickle a pyzabbix.ZabbixAPI class instance with the following code: 我无法使用以下代码腌制pyzabbix.ZabbixAPI类实例:
from pyzabbix import ZabbixAPI
from pickle import dumps
api = ZabbixAPI('http://platform.autuitive.com/monitoring/')
print dumps(api)
It results in the following error: 它导致以下错误:
Traceback (most recent call last):
File "zabbix_test.py", line 8, in <module>
print dumps(api)
File "/usr/lib/python2.7/pickle.py", line 1374, in dumps
Pickler(file, protocol).dump(obj)
File "/usr/lib/python2.7/pickle.py", line 224, in dump
self.save(obj)
File "/usr/lib/python2.7/pickle.py", line 306, in save
rv = reduce(self.proto)
File "/usr/lib/python2.7/copy_reg.py", line 84, in _reduce_ex
dict = getstate()
TypeError: 'ZabbixAPIObjectClass' object is not callable
Well, in the documentation it says: 好吧,在文档中说:
instances of such classes whose
__dict__
or the result of calling__getstate__()
is picklable (see section The pickle protocol for details).此类类的实例,它们的
__dict__
或调用__getstate__()
的结果是可__getstate__()
有关详细信息,请参见“腌制协议”一节)。
And it would appear this class isn't one. 看来这堂课不是一个。 If you really need to do this, then consider writing your own pickling routines.
如果您确实需要这样做,那么可以考虑编写自己的酸洗程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.