[omniORB] omniORBpy and multithreading

Duncan Grisby dgrisby@uk.research.att.com
Wed, 27 Jun 2001 16:35:55 +0100


On Tuesday 12 June, Sergio Murru wrote:

> We're using Python embedded in a C++ application.
> We run concurrent python scripts and to avoid the sharing of variables
> we run each script after a call to Py_NewInterpreter(). 
> This worked fine until we tried to use omniORBpy.
>
> When we try to run more than one script implementing a CORBA server, the 
> 
> from omniORB import CORBA, PortableServer
> 
> line in the second thread fails, reporting a
> 
> _omnipy.omni_func module not found.

The root of the problem is that omniORBpy has to integrate quite
tightly with the Python interpreter. Unfortunately, at the moment you
can't use omniORBpy from more than one Python interpreter instance in
a single process. I can't think of any easy way of supporting it,
either, since when omniORB does an up-call due to an incoming CORBA
call, it has to acquire the Python interpreter lock. With more than
one interpreter present, it wouldn't know which lock to acquire.

The problem you're seeing is just a side effect of the fact that
omniORBpy is assuming there to be only one Python interpreter. When
you import _omnipy in a second interpreter, it doesn't think it needs
to initialise everything. That could be fixed, but there's not much
point since it wouldn't work anyway.

It's probably not impossible to solve, and I'll think about it. But
for the moment, I'm afraid you can't do what you are trying to do.

The only partial way out is for you to either use multiple threads
within a single Python interpreter, or fork to separate Python
processes.

Sorry I can't be of more help.

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --