~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/tutorial/listings/finger/fingerPBclient.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
# test the PB finger on port 8889
 
2
# this code is essentially the same as
 
3
# the first example in howto/pb-usage
 
4
 
 
5
from twisted.spread import pb
 
6
from twisted.internet import reactor
 
7
 
 
8
def gotObject(object):
 
9
    print "got object:", object
 
10
    object.callRemote("getUser","moshez").addCallback(gotData)
 
11
# or
 
12
#   object.callRemote("getUsers").addCallback(gotData)
 
13
   
 
14
def gotData(data):
 
15
    print 'server sent:', data
 
16
    reactor.stop()
 
17
    
 
18
def gotNoObject(reason):
 
19
    print "no object:",reason
 
20
    reactor.stop()
 
21
 
 
22
factory = pb.PBClientFactory()
 
23
reactor.connectTCP("127.0.0.1",8889, factory)
 
24
factory.getRootObject().addCallbacks(gotObject,gotNoObject)
 
25
reactor.run()
 
26