Hello there! :)

So, for those of you who want to write distributed systems easily in Python or are just curious about the subject, I was studying about Java RMI for my Distributed Systems class and I always get thrilledto know that I need to write Java code. Nothing against good ol’ Java, it’s just not my vibe these days but I’d happily do it if convinced. Since I was just studying and trying to learn a concept, I searched for a Python alternative.

And I found it.

Python Smart Objects are implemented in this library named [Pyro] (http://pyro4.readthedocs.io/en/stable/) and it amazes me how simple and easy it is to write a distributed application with it. It works on multiple Python versions, it is being actively updated by its author and its seamlessly to use.

I’ve made a small chat distributed system named mess that makes use of Pyro, but I’ll show a simpler version of the code here.

This is the code for the client. It creates a proxy to the server and sends a text message.

And this is the code for the server. It locates a name server (Pyro comes with one and you just need to use it with python -m Pyro4.naming in the same machine as the server).

And that’s all :) You can run multiple clients, but only one server per name, so if you need multiple servers for some reason you’re gonna need to register names with a identifier.

Disclaimer: I never needed to use Python Smart Objects neither Java RMI in a real world application. I came across RMI in a college class about Distributed Systems. It’s a nice thing to study as an alternative because it is the kind of knowledge that you might need in the future. Nowadays, if I really need distributed systems with high performance, I’d try GRPC, probably with Go.