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 (32 lines) | stat: -rw-r--r-- 1,274 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
23
24
25
26
27
28
29
30
31
32
import Pyro5.api
import uuid


# example: set a single correlation id on the context that should be passed along
Pyro5.api.current_context.correlation_id = uuid.uuid4()
print("correlation id set to:", Pyro5.api.current_context.correlation_id)


uri = input("Enter the URI of the server object: ")

print("\n------- get annotations via normal proxy and the call context... -----\n")

with Pyro5.api.Proxy(uri) as proxy:
    print("normal call")

    Pyro5.api.current_context.annotations = {"XYZZ": b"custom annotation from client (1)"}
    result = proxy.echo("hi there - new method of annotation access in client")
    print("Annotations in response were: ")
    for key, value in Pyro5.api.current_context.response_annotations.items():
        print("  ", key, "->", bytes(value))

    print("\noneway call")
    Pyro5.api.current_context.annotations = {"XYZZ": b"custom annotation from client (2)"}
    proxy.oneway("hi there ONEWAY - new method of annotation access in client")
    print("Annotations in response were: ")
    for key, value in Pyro5.api.current_context.response_annotations.items():
        print("  ", key, "->", bytes(value))
    print("(should be an empty result because oneway!)")


print("\nSee the console output on the server for more results.")