Reputation: 1029
I wish to create a sock.Socket object from a main program using multiprocessing to avoid blocking the main program if the socket is not available during the creation process. The socket gets created but can not be returned to the main program.
After some reading it seems that objects can not be shared between python processes. It there a possible design pattern to circumvent this? Is multiprocessing suitable for this application or should I be considering another approach?
Upvotes: 1
Views: 186
Reputation: 28390
You should keep it really simple and have a socket handler thread which:
Then everything becomes non-blocking. This is a much cleaner design pattern especially if you use pubsub.
Upvotes: 1