~vishvananda/nova/network-refactor

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/listings/pb/pb1client.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
# Copyright (c) 2009 Twisted Matrix Laboratories.
 
4
# See LICENSE for details.
 
5
 
 
6
from twisted.spread import pb
 
7
from twisted.internet import reactor
 
8
 
 
9
def main():
 
10
    factory = pb.PBClientFactory()
 
11
    reactor.connectTCP("localhost", 8800, factory)
 
12
    def1 = factory.getRootObject()
 
13
    def1.addCallbacks(got_obj1, err_obj1)
 
14
    reactor.run()
 
15
 
 
16
def err_obj1(reason):
 
17
    print "error getting first object", reason
 
18
    reactor.stop()
 
19
 
 
20
def got_obj1(obj1):
 
21
    print "got first object:", obj1
 
22
    print "asking it to getTwo"
 
23
    def2 = obj1.callRemote("getTwo")
 
24
    def2.addCallbacks(got_obj2)
 
25
 
 
26
def got_obj2(obj2):
 
27
    print "got second object:", obj2
 
28
    print "telling it to do three(12)"
 
29
    obj2.callRemote("three", 12)
 
30
 
 
31
main()