如何在谷歌应用程序引擎数据存储区中存储套接字对象(也可以腌制套接字对象)

时间:2015-10-10 04:00:44

标签: python sockets google-app-engine pickle google-app-engine-python

我需要在基于GAE Python的应用程序中将Socket对象存储到datastore / memcache中。

我采取的方法是 1.使用pickle.dumps将套接字对象转换为字符串 2.需要时,使用pickle.loads(<pickledSock>)

检索此字符串并取消删除

下面是完整的错误消息,但主要部分是:

TypeError: __init__() got an unexpected keyword argument '_sock'

这是否意味着我无法使用上述方法,因为&#34; unpickling&#34;不会工作吗?

ssl_sock2Use=pickle.loads(pickledSock)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/pickle.py", line 1382, in loads
    return Unpickler(file).load()
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/pickle.py", line 858, in load
    dispatch[key](self)
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/pickle.py", line 1217, in load_build
    setstate(state)
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/socket.py", line 181, in __setstate__
    self.__init__(_sock=_sock)
TypeError: __init__() got an unexpected keyword argument '_sock'

0 个答案:

没有答案