Skip to content

Instantly share code, notes, and snippets.

@biancarosa
Created August 13, 2018 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biancarosa/26f52dbbeadfa63d725d561eafa52a0e to your computer and use it in GitHub Desktop.
Save biancarosa/26f52dbbeadfa63d725d561eafa52a0e to your computer and use it in GitHub Desktop.
from datetime import datetime
import Pyro4
@Pyro4.expose
class Chat(object):
def send_message(self, text):
now = datetime.now()
print(f'{text} - received at {now:%H:%M:%S} \n')
def start_server():
daemon = Pyro4.Daemon()
ns = Pyro4.locateNS()
uri = daemon.register(Chat)
ns.register('mess.server', str(uri))
print(f'Ready to listen')
daemon.requestLoop()
if __name__ == '__main__':
try:
start_server()
except (KeyboardInterrupt, EOFError):
print('Goodbye! (:')
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment