[omniORB] Threading in python
Thomas Lockhart
lockhart@fourpalms.org
Fri, 03 May 2002 08:03:34 -0700
> orb.run() shouldn't block other threads. It works fine for me. Can you
> post some minimal code that shows the problem?
Output and code are included below. fwiw, ORBit-python seems to show the
same behavior. I've looked at the python executable (installed from RPM
on Mandrake-8.1) and it references the pthreads dynamic library (I was
thinking it might be a user threads vs kernel threads issue). Linux
kernel is 2.4.8 from the Mandrake distro.
If I omit the call to orb.run() then the test thread runs to completion
and the process ends gracefully. I get the same behaviors if more than
one test thread is started. I know I'm doing something wrong (and it is
likely to be trivial), but haven't figured out what! Thanks for any
suggestions...
- Thomas
Example output:
myst* ./pingclient.py
Result for RootPOA is 810b060
Starting test 1...
test 1: 0
test 1: 1
test 1: 2
test 1: 3
Calling orb.run()
Test code:
#!/usr/bin/env python
import sys, time, threading
import omniORB
import CORBA
def test(n):
print "Starting test %s..." % n
for i in range (10):
time.sleep(1)
print "test %s: %d" % (n, i)
print "Exiting test %s" % n
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")
poa._get_the_POAManager().activate()
t1 = threading.Thread(name="t1", args=(1,), target=test)
t1.start()
time.sleep(4)
print "Calling orb.run()"
orb.run()
print "Exiting test"