pulling multiple instances of a module into memory

G

Gabriel Jiva

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
 
G

Grooooops

in spam.py, how about something like this:

try:
eggs.someFunction()
except:
import eggs
 
I

infidel

Do you have control over the eggs.so module? Seems to me the best
answer is to make the start method return a connection object

conn1 = eggs.start('Connection1')
conn2 = eggs.start('Connection2')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top