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

« back to all changes in this revision

Viewing changes to examples/threadmobile/client.py

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz, Bernd Zeimetz, Sandro Tosi
  • Date: 2008-03-23 12:58:43 UTC
  • mfrom: (4.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080323125843-8zrvz1whkwzdyjxk
Tags: 3.7-2
[ Bernd Zeimetz ]
* debian/control:
  - Adding Homepage field, removing pseudo-field from description
  - Rename XS-Vcs-* fields to Vcs-* (dpkg supports them now)
  - Updating my email address.

[ Sandro Tosi ]
* debian/control
  - uniforming Vcs-Browser field
  - bump Standards-Version to 3.7.3
  - bump versioned build-dep on python-central to at least 0.6
* debian/copyright
  - converted to UTF-8
  - renamed copyright section to license
  - indented upstream author and license with 4 spaces
  - added copyright notice
* debian/pyro-doc.doc-base
  - updated section
  - removed empty tailing lines
* debian/pyro-gui.install
  - removed python-central directory (moved to debian/rules)
* debian/pyro.install
  - removed python-central directory (moved to debian/rules)
* debian/rules
  - updated due to new python-central directories structure (Closes:
    #472039)
  - integrate files under python-central directory into dh_install call
  - moved dh_install calls to install target

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import threading
 
2
import time
 
3
import Pyro.core
 
4
import Pyro.util
 
5
import params.parameters
 
6
 
 
7
HOST="localhost"
 
8
URI = "PYROLOC://%s/test.threadmobile"
 
9
NUM_THREADS=10
 
10
 
 
11
if not Pyro.config.PYRO_MOBILE_CODE:
 
12
        raise SystemExit("PYRO_MOBILE_CODE not enabled")
 
13
if Pyro.config.PYRO_XML_PICKLE=='gnosis' and Pyro.config.PYRO_GNOSIS_PARANOIA>=0:
 
14
        raise SystemExit("Using gnosis xml pickle but PYRO_GNOSIS_PARANOIA needs to be -1")
 
15
 
 
16
 
 
17
startEvent = threading.Event()
 
18
 
 
19
def worker():
 
20
        obj=Pyro.core.getProxyForURI(URI % HOST)
 
21
        startEvent.wait()
 
22
        name = threading.currentThread().getName()
 
23
        print "worker", name
 
24
        p = params.parameters.Parameter(name)
 
25
        try:
 
26
                result=obj.method(p)
 
27
                print "result=",result,"calling method on it..."
 
28
                result.method()
 
29
        except Exception,x:
 
30
                print "".join(Pyro.util.getPyroTraceback(x))
 
31
        time.sleep(1)
 
32
        print "exit"
 
33
 
 
34
 
 
35
HOST=raw_input("server host (empty for %s): " % HOST) or HOST   
 
36
 
 
37
workers=[]
 
38
for i in range(NUM_THREADS):
 
39
        w=threading.Thread(target=worker)
 
40
        workers.append(w)
 
41
        w.start()
 
42
        time.sleep(0.1)
 
43
 
 
44
time.sleep(1)
 
45
print "starting!"
 
46
startEvent.set()
 
47
 
 
48
print "running" 
 
49
 
 
50
for w in workers:
 
51
        w.join()
 
52
 
 
53
print "done!"