By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

pulling multiple instances of a module into memory

P: n/a
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

Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
in spam.py, how about something like this:

try:
eggs.someFunction()
except:
import eggs

Jul 19 '05 #2

P: n/a
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')

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.