~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/listings/pb/exc_server.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
class MyError(pb.Error):
 
10
    """This is an Expected Exception. Something bad happened."""
 
11
    pass
 
12
 
 
13
class MyError2(Exception):
 
14
    """This is an Unexpected Exception. Something really bad happened."""
 
15
    pass
 
16
 
 
17
class One(pb.Root):
 
18
    def remote_broken(self):
 
19
        msg = "fall down go boom"
 
20
        print "raising a MyError exception with data '%s'" % msg
 
21
        raise MyError(msg)
 
22
    def remote_broken2(self):
 
23
        msg = "hadda owie"
 
24
        print "raising a MyError2 exception with data '%s'" % msg
 
25
        raise MyError2(msg)
 
26
 
 
27
def main():
 
28
    reactor.listenTCP(8800, pb.PBServerFactory(One()))
 
29
    reactor.run()
 
30
 
 
31
if __name__ == '__main__':
 
32
    main()