[C++-sig] scope() rules?

David Abrahams dave at boost-consulting.com
Thu Sep 5 00:28:10 CEST 2002


From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>


> --- David Abrahams <dave at boost-consulting.com> wrote:
> > > Is there a guarantee that only one module is dlopen'ed by Python at
any
> > given
> > > time? Have threading issues be considered in the design? Or are these
> > quesions
> > > not relevant?
> >
> > I'm pretty sure that Python only imports one module at a time. That's
what
> > I remember, anyway.
> >
> > If that weren't the case we'd have lots more problems than just the
global
> > current scope().
>
> Following your advice from a while ago I use PyImport_ImportModule() to
import
> a module with Python bindings for array types (flex.so) while importing
other
> modules that make use of these bindings (e.g. fftpack.so). I have strong
> evidence that Python dlopen's the flex.so module before the
initialization of
> fftpack.so is finished, using print statements at the beginning and the
end of
> the extern "C" init functions.

Sorry, I should have said that all imports are synchronized through the
GIL.

> from scitbx import fftpack
> /net/cci/rwgk/bpl2/scitbx/fftpack/boost_python/fftpack_module.cpp(380)
> /net/cci/rwgk/bpl2/scitbx/array_family/boost_python/flex_module.cpp(138)
> /net/cci/rwgk/bpl2/scitbx/array_family/boost_python/flex_module.cpp(141)
> /net/cci/rwgk/bpl2/scitbx/fftpack/boost_python/fftpack_module.cpp(382)
>
> Right now, fftpack.so does not use the deprecated module object, but uses
the
> free def() functions. However, flex_module.cpp still uses the old module
> object. My regression tests work just fine. What will happen if I convert
> flex.so over to the free def() functions?

It should work without problems. If it doesn't give me a small use case and
I'll fix it.


-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com






More information about the Cplusplus-sig mailing list