~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to doc/examples/pbsimpleclient.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2004-06-21 22:01:11 UTC
  • mto: (2.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040621220111-vkf909euqnyrp3nr
Tags: upstream-1.3.0
ImportĀ upstreamĀ versionĀ 1.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
from twisted.spread import pb
19
 
from twisted.internet import main
20
 
def gotObject(object):
21
 
    print "got object:",object
22
 
    object.callRemote("echo", "hello network").addCallback(gotEcho)
23
 
def gotEcho(echo):
24
 
    print 'server echoed:',echo
25
 
    main.shutDown()
26
 
def gotNoObject(reason):
27
 
    print "no object:",reason
28
 
    main.shutDown()
29
 
pb.getObjectAt("localhost", 8789, 30).addCallbacks(gotObject, gotNoObject)
30
 
main.run()
 
19
from twisted.internet import reactor
 
20
from twisted.python import util
 
21
 
 
22
factory = pb.PBClientFactory()
 
23
reactor.connectTCP("localhost", 8789, factory)
 
24
d = factory.getRootObject()
 
25
d.addCallback(lambda object: object.callRemote("echo", "hello network"))
 
26
d.addCallback(lambda echo: 'server echoed: '+echo)
 
27
d.addErrback(lambda reason: 'error: '+str(reason.value))
 
28
d.addCallback(util.println)
 
29
d.addCallback(lambda _: reactor.stop())
 
30
reactor.run()