File: singlethread.py

package info (click to toggle)
python-omniorb 3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 3,128 kB
  • ctags: 3,321
  • sloc: cpp: 13,969; python: 8,883; sh: 2,576; xml: 107; makefile: 95; ansic: 35
file content (36 lines) | stat: -rwxr-xr-x 872 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python

# Single threaded POA.

import sys, time
import CORBA, PortableServer

import _GlobalIDL, _GlobalIDL__POA

class Echo_i (_GlobalIDL__POA.Echo):
    def echoString(self, mesg):
        print "echoString() called with message:", mesg
        if mesg == "re-enter":
            eo.echoString("re-entrant call")
        elif mesg == "shutdown":
            orb.shutdown(0)
        return mesg

# Initialise the ORB and activate the root POA.
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")
poaManager = poa._get_the_POAManager()
poaManager.activate()

# Create a single-threaded child POA
ps = [ poa.create_thread_policy(PortableServer.SINGLE_THREAD_MODEL) ]

child = poa.create_POA("MyPOA", poaManager, ps)

ei = Echo_i()
child.activate_object(ei)
eo = ei._this()

print orb.object_to_string(eo)

orb.run()