English 中文(简体)
我有一个小错,不知道他指的是谁会知道什么意思?
原标题:I have a cPickle error and does not know what he means maybe anyone know what this means?

我使用一种程序通信监测中心,其代码如下:

    HOST =        # local host
    PORT = 50000
    SERVER_ADDRESS = HOST, PORT

    # set up server socket
    s = socket.socket()
    s.bind(SERVER_ADDRESS)
    s.listen(1)

    while True:
        conn, addr = s.accept()
        connFile = conn.makefile()
        name, args, kwargs = cPickle.load(connFile)
           name = cPickle.load(connFile)
        args = cPickle.load(connFile)
        kwargs = cPickle.load(connFile)   
        res = _exportedMethods[name](*args,**kwargs)
        cPickle.dump(res,connFile) ; connFile.flush()
        conn.close()

客户网站:

class RemoteFunction(object):
    def __init__(self,serverAddress,name):
        self.serverAddress = serverAddress
        self.name = name
    def __call__(self,*args,**kwargs):
        s = socket.socket()
        s.connect(self.serverAddress)
        f = s.makefile()
        cPickle.dump((self.name, args, kwargs), f)
           cPickle.dump(self.name,f)
        cPickle.dump(args,f)     
        cPickle.dump(kwargs,f)      
        f.flush()
        res = cPickle.load(f)
        s.close()
        return res

def machine_changed_signal(machine):
    HOST =   
    PORT = 50000
    SERVER_ADDRESS = HOST, PORT
    advise = RemoteFunction(SERVER_ADDRESS, changes )
    advise(machine)

我收到以下错误信息:

Traceback (most recent call last):
  File "/home/manch011/disserver/src/disserver/gui/backends/receiver.py", line 71, in run
    args = cPickle.load(connFile)
cPickle.UnpicklingError: pickle data was truncated

After my changes the new i get the following error message:

Traceback (most recent call last):
File "/home/manch011/disserver/src/disserver/gui/backends/receiver.py", line 69, in run
name, args, kwargs = cPickle.load(connFile)
EOFError

我不熟悉小盘问,因此不能说是这样,有人可以向我解释。

Thanks in advance Chis

问题回答

当你把你的袖珍改成像文档的物体时(connFile = conn.makefile(),你在你的档案中可以提供所有材料。 当你做<代码>cPickle.load(connFile)时,您的袖珍/档案中的所有材料都用插头装上,因此,在第二次电话中,没有任何东西可以阻塞,这在提出例外时引起了什么抱怨。

如果你想提取功能名称、动力和高射线,则在第一个<代码>cPickle.load(connFile)上不计算你的所有数据。

客户方面:

cPickle.dump((function_name, args, kwargs), client_socket_as_file)

服务器边

name, args, kwargs = cPickle.load(connFile)




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签