File: client.py

package info (click to toggle)
pyro5 5.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,124 kB
  • sloc: python: 14,328; makefile: 161; sh: 66; javascript: 62
file content (22 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sys
import datetime
import Pyro5.api
import Pyro5.errors
from customdata import CustomData


sys.excepthook = Pyro5.errors.excepthook

# teach Serpent how to serialize our data class
Pyro5.api.SerializerBase.register_class_to_dict(CustomData, CustomData.to_dict)


with Pyro5.api.Proxy("PYRONAME:example.blobdispatcher") as dispatcher:
    while True:
        topic = input("Enter topic to send data on (just enter to quit) ").strip()
        if not topic:
            break
        # create our custom data object and send it through the dispatcher
        data = CustomData(42, "hello world", datetime.datetime.now())
        dispatcher.process_blob(Pyro5.api.SerializedBlob(topic, data))
        print("processed")