~ubuntu-branches/debian/sid/pyro/sid

« back to all changes in this revision

Viewing changes to examples/servertypes/server.py

  • Committer: Bazaar Package Importer
  • Author(s): Carl Chenet, Carl Chenet, Jakub Wilk
  • Date: 2010-09-14 01:04:28 UTC
  • Revision ID: james.westby@ubuntu.com-20100914010428-02r7p1rzr7jvw94z
Tags: 1:3.9.1-2
[Carl Chenet]
* revert to 3.9.1-1 package because of the development status 
  of the 4.1 package is unsuitable for stable use
  DPMT svn #8557 revision (Closes: #589172) 
* added debian/source
* added debian/source/format
* package is now 3.0 (quilt) source format
* debian/control
  - Bump Standards-Version to 3.9.1

[Jakub Wilk]
* Add ‘XS-Python-Version: >= 2.5’ to prevent bytecompilation with python2.4
  (closes: #589053).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import time
2
 
import Pyro
3
 
from Pyro import threadutil
4
 
 
5
 
class Server(object):
6
 
    def __init__(self):
7
 
        self.callcount=0
8
 
    def reset(self):
9
 
        self.callcount=0
10
 
    def getcount(self):
11
 
        return self.callcount   # the number of completed calls
12
 
    def getconfig(self):
13
 
        return Pyro.config.asDict()
14
 
    def delay(self):
15
 
        threadname=threadutil.currentThread().getName()
16
 
        print "delay called in thread",threadname
17
 
        time.sleep(1)
18
 
        self.callcount+=1
19
 
        return threadname
20
 
    def onewaydelay(self):
21
 
        threadname=threadutil.currentThread().getName()
22
 
        print "onewaydelay called in thread",threadname
23
 
        time.sleep(1)
24
 
        self.callcount+=1
25
 
 
26
 
 
27
 
######## main program
28
 
 
29
 
Pyro.config.SERVERTYPE="undefined"
30
 
servertype=raw_input("Servertype threaded or select (t/s)?")
31
 
if servertype=="t":
32
 
    Pyro.config.SERVERTYPE="thread"
33
 
if servertype=="s":
34
 
    Pyro.config.SERVERTYPE="select"
35
 
 
36
 
daemon=Pyro.core.Daemon()
37
 
obj=Server()
38
 
uri=daemon.register(obj)
39
 
ns=Pyro.naming.locateNS()
40
 
ns.remove("example.servertypes")
41
 
ns.register("example.servertypes", uri)
42
 
print "Server is ready."
43
 
daemon.requestLoop()