泡菜问题 [英] pickle problem

查看:68
本文介绍了泡菜问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以帮助解决我目前有问题的问题。我正在尝试设置一个prefork tcp服务器。

具体来说,我正在设置一个服务器,用于分发儿童并拥有它们

监听用于创建的管道os.pipe()。

组的父进程在给定端口上启动inet:tcp服务器。在父母中,在

a" socket.accept()"之后,我试图将连接对象腌制成

通过IPC管道发送(如上所述)以前),但我得到以下

错误:


文件" /usr/lib/python2.4/copy_reg.py" ;,第76行,在_reduce_ex中

引发TypeError("一个定义__slots__的类没有"

TypeError:一个定义__slots__而没有定义的类

__getstate__不能腌渍


有没有人知道这方面的解决方法?也许我的方法这个

是错的?任何帮助都将不胜感激。


Jay

I''m wondering if anyone can help with a workaround for a problem I
currently have. I''m trying to set up a prefork tcp server.
Specifically, I''m setting up a server that forks children and has them
listen on pipes created with os.pipe(). The parent process for the
group starts an inet:tcp server on a given port. In the parent, after
a "socket.accept()", I''m trying to pickle the connection object to
send over an IPC pipe (as stated previously), but I get the following
error:

File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining
__getstate__ cannot be pickled

Does anyone know of a workaround for this? Maybe my approach to this
is wrong? Any help would be appreciated.

Jay

推荐答案

5月7日,11:02 * pm,krustymon ... @ gmail.com写道:
On May 7, 11:02*pm, krustymon...@gmail.com wrote:

我想知道是否有人可以帮助解决我目前有问题的解决方法。*我正在尝试设置一个prefork tcp服务器。

具体来说,我是setti打开一个供孩子们使用并拥有它们的服务器

监听用os.pipe()创建的管道。 *

组的父进程在给定端口上启动inet:tcp服务器。 *在父母中,在

a" socket.accept()"之后,我试图将连接对象腌制成

通过IPC管道发送(如之前说过,但我得到以下

错误:


文件" /usr/lib/python2.4/copy_reg.py" ;,第76行,在_reduce_ex

* *引发TypeError("一个定义__slots__的类没有"

TypeError:一个定义__slots__的类而没有定义

__getstate__无法腌制


有没有人知道这方面的解决方法?*也许我的方法这个

是错的?*任何帮助将不胜感激。


Jay
I''m wondering if anyone can help with a workaround for a problem I
currently have. *I''m trying to set up a prefork tcp server.
Specifically, I''m setting up a server that forks children and has them
listen on pipes created with os.pipe(). *The parent process for the
group starts an inet:tcp server on a given port. *In the parent, after
a "socket.accept()", I''m trying to pickle the connection object to
send over an IPC pipe (as stated previously), but I get the following
error:

File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
* * raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining
__getstate__ cannot be pickled

Does anyone know of a workaround for this? *Maybe my approach to this
is wrong? *Any help would be appreciated.

Jay



该组目前认为酸洗套管对象不是最佳的

to赚钱的目的。我们可以告诉你很好的方法来完成

你打算做同样的事情。我觉得它很有教育意义;那就是'b
罚款在我的书中。部分抵抗来自抵抗

君主制。瓶颈是第二个Python进程的开始。


但是有许多对象无法被腌制。如果你能够客观地确定酸洗套接字下一步的优先顺序,那么你可能会在它进入Python时更快地找到b $ b。但那是'

的一部分;扬声器推荐反对。


我们接受你的想法是围绕插座屏障进行处理。

你能否在N部分关闭服务器,听到连接在N + 1部分,

在N + 2中生成一个新服务器,并在N + 3中处理第一个服务器?它是否适合你的想法?

The group currently holds that pickling socket objects is non-optimal
to the ends of making money. We can tell you good ways to accomplish
what you set out to do all the same. I find it educational; that''s
fine in my book. Part of the resistence comes from a resistence to
monarchy. The bottleneck is the starting of a second Python process.

There are a number of objects which can''t be pickled, though. If you
can objectively prioritize the next step in pickling sockets, you may
find out sooner when it will come in to Python. But that''s the hard
part; speaker recommends against.

We accept your idea is to get a process around the socket barrier.
Can you close the server in Part N, hear the connection in Part N+1,
spawn a new server in N+2, and handle the first one in N+3? Is it
suitable to your minds?


kr ********** @ gmail.com 写道:
kr**********@gmail.com wrote:

我想知道是否有人可以提供帮助有一个问题的解决方法我现在有
。我正在尝试设置一个prefork tcp服务器。

具体来说,我正在设置一个服务器,用于分发儿童并拥有它们

监听用于创建的管道os.pipe()。

组的父进程在给定端口上启动inet:tcp服务器。在父母中,在

a" socket.accept()"之后,我试图将连接对象腌制成

通过IPC管道发送(如上所述)以前),但我得到以下

错误:


文件" /usr/lib/python2.4/copy_reg.py" ;,第76行,在_reduce_ex中

引发TypeError("一个定义__slots__的类没有"

TypeError:一个定义__slots__而没有定义的类

__getstate__不能被腌渍


有没有人知道这方面的解决方法?也许我的方法这个

是错的?任何帮助都将不胜感激。
I''m wondering if anyone can help with a workaround for a problem I
currently have. I''m trying to set up a prefork tcp server.
Specifically, I''m setting up a server that forks children and has them
listen on pipes created with os.pipe(). The parent process for the
group starts an inet:tcp server on a given port. In the parent, after
a "socket.accept()", I''m trying to pickle the connection object to
send over an IPC pipe (as stated previously), but I get the following
error:

File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining
__getstate__ cannot be pickled

Does anyone know of a workaround for this? Maybe my approach to this
is wrong? Any help would be appreciated.



错误信息非常清楚我会说。你使用插槽 - 所以你是

自己负责使用
__getstate__和__setstate__。看看pickle-docs应该给你

一个想法。


但真正简单的解决方案是:做不使用插槽。他们是打算作为内存消耗优化技术,*不*作为我想明确声明我的

属性-mechanism。所以 - 摆脱它们并成为一个快乐的

pickler。


Diez

The error-message is pretty clear I''d say. You use slots - so you are
responsible yourself for implementing the pickling-protocol using
__getstate__ and __setstate__. Looking at the pickle-docs should give you
an idea.

But the really easy solution is: do not use slots. They are intended as
memory-consumption optimization technique, *not* as "I want to declare my
attributes explicitly"-mechanism. So - get rid of them and be a happy
pickler.

Diez


5月8,5:48 am,Diez B. Roggisch, < de ... @nospam.web.dewrote:
On May 8, 5:48 am, "Diez B. Roggisch" <de...@nospam.web.dewrote:

krustymon ... @ gmail.com写道:
krustymon...@gmail.com wrote:

我想知道是否有人可以帮助解决我目前有问题的问题。我正在尝试设置一个prefork tcp服务器。

具体来说,我正在设置一个服务器,用于分发儿童并拥有它们

监听用于创建的管道os.pipe()。

组的父进程在给定端口上启动inet:tcp服务器。在父母中,在

a" socket.accept()"之后,我试图将连接对象腌制成

通过IPC管道发送(如上所述)以前),但我得到以下

错误:
I''m wondering if anyone can help with a workaround for a problem I
currently have. I''m trying to set up a prefork tcp server.
Specifically, I''m setting up a server that forks children and has them
listen on pipes created with os.pipe(). The parent process for the
group starts an inet:tcp server on a given port. In the parent, after
a "socket.accept()", I''m trying to pickle the connection object to
send over an IPC pipe (as stated previously), but I get the following
error:


文件" /usr/lib/python2.4/ copy_reg.py",第76行,在_reduce_ex中

引发TypeError("一个定义__slots__的类,没有"

TypeError:一个定义__slots__而没有定义
__getstate__无法腌制
File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining
__getstate__ cannot be pickled


有没有人知道这方面的解决方法?也许我对此的方法

是错的?任何帮助都会受到赞赏。
Does anyone know of a workaround for this? Maybe my approach to this
is wrong? Any help would be appreciated.



错误信息非常清楚我会说。你使用插槽 - 所以你是

负责使用

__getstate__和__setstate__来实施pickling-protocol。查看pickle-docs应该给出你好吗?
一个想法。


但真正简单的解决方案是:不要使用插槽。它们旨在作为内存消耗优化技术,*不*作为我想明确声明我的

属性-mechanism。所以 - 摆脱它们并成为一个快乐的

pickler。


Diez


The error-message is pretty clear I''d say. You use slots - so you are
responsible yourself for implementing the pickling-protocol using
__getstate__ and __setstate__. Looking at the pickle-docs should give you
an idea.

But the really easy solution is: do not use slots. They are intended as
memory-consumption optimization technique, *not* as "I want to declare my
attributes explicitly"-mechanism. So - get rid of them and be a happy
pickler.

Diez



事情是,我不是选择使用插槽。我正在使用标准的

lib" socket"类,显然使用插槽。

The thing is, I''m not using slots by choice. I''m using the standard
lib "socket" class, which apparently uses slots.


这篇关于泡菜问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆