Multiprocesing socket - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Multiprocesing socket (/thread-34810.html) |
Multiprocesing socket - samuelbachorik - Sep-02-2021 Hi iam trying to sent numpy array to multiprocesing socket and always getting error Does somebody know where is problem ? This is my server from multiprocessing.connection import Listener address = ('localhost', 6000) listener = Listener(address, authkey= 'secret password'.encode('utf-8')) conn = listener.accept() while True: msg = conn.recv() print(msg)And this is my client that sent numpy array to server from multiprocessing.connection import Client import numpy as np a = np.zeros(5) address = ('localhost', 6000) conn = Client(address, authkey= 'secret password'.encode('utf-8')) conn.send(a) conn.close()And iam getting this output- server actually prints out that numpy array but anyway it throws error.
RE: Multiprocesing socket - bowlofred - Sep-02-2021 Quote:recv() So the EOFError is expected when the data is done. If you don't want this to exit your program, you need to put it in a try/except and handle the case where the exception is thrown. while True: try: msg = conn.recv() print(msg) except EOFError: print("Connection closed.") break() RE: Multiprocesing socket - samuelbachorik - Sep-02-2021 (Sep-02-2021, 05:46 PM)bowlofred Wrote:Quote:recv() Thank you a lot now i uderstand ! |