I have 2 independent files: The first one is client.py and in it i should create some object using Record and then to serialize it using pickle class and then to send it with socket to the second file which is server.py and the server should de-serialize this bytes object to the original object
client.py:
from pyrecord import Record
import pickle
clientSock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
clientSock.connect(("localhost",48621))
Message1Obj=Record.create_type('Message1Obj','name','address')
message1Data = Message1Obj("KB","aa")
message1Serlization = pickle.dumps(message1Data)
clientSock.send(message1Serlization)
server.py
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.bind(("localhost",48621))
sock.listen(5)
con,adr = sock.accept()
message1 = con.recv(8192)
Message1Obj = pickle.loads(message1)
but i get this error on the servers.py:
AttributeError: Can't get attribute 'Message1Obj' on module 'main' from 'server.py'
I understood from previous answers that pickle.dump saves also the module that the object is in, Is it possible to load the serialized object in other module?