pulling multiple instances of a module into memory

Gabriel Jiva jivadent at gmail.com
Mon Jun 27 10:06:07 EDT 2005


I have a Python app, spam.py, that uses a C shared library, eggs.so.
This shared library is an interface that makes connections to another
system (Ham), and among other things uses callback functions.
Therefore, if I want to make multiple connections to Ham, I need
eggs.so to be instantiated in memory multiple times so that everything
works fine.

Right now, in spam.py, let's say I want to make two connections to the
Ham system.  I call

eggs.start('Connection1')
eggs.start('Connection2')

On the second one, I get a 'duplicate call' error.  Because Python is
optimized to only load a module into memory once, I can never make more
than one connection from the same Python script.

Any ideas to work around this would be great.

Gabriel




More information about the Python-list mailing list