~soren/nova/iptables-security-groups

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/listings/pb/cache_receiver.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.application import service, internet
 
7
from twisted.internet import reactor
 
8
from twisted.spread import pb
 
9
import cache_classes
 
10
 
 
11
class Receiver(pb.Root):
 
12
    def remote_takePond(self, pond):
 
13
        self.pond = pond
 
14
        print "got pond:", pond # a DuckPondCache
 
15
        self.remote_checkDucks()
 
16
    def remote_checkDucks(self):
 
17
        print "[%d] ducks: " % self.pond.count(), self.pond.getDucks()
 
18
    def remote_ignorePond(self):
 
19
        # stop watching the pond
 
20
        print "dropping pond"
 
21
        # gc causes __del__ causes 'decache' msg causes stoppedObserving
 
22
        self.pond = None
 
23
    def remote_shutdown(self):
 
24
        reactor.stop()
 
25
 
 
26
application = service.Application("copy_receiver")
 
27
internet.TCPServer(8800, pb.PBServerFactory(Receiver())).setServiceParent(
 
28
    service.IServiceCollection(application))