Problem with using singleton receip in python

V

Vineet Jain

I started off doing the following:


Class someClass(Singleton):

This worked fine but was not elegant. I'm using a large number of Singleton
classes. And Having to create a new object and discard it millions of times
added up. My functions get called many many times.

So I decided to use a GlobalMadules class which has all my global classes
and resources. I initialize this at the begining of my program.

The problem is that in the main program I have to do:

from GlobalModules import initGlobalModule
from GlobalModules.someGlobalClass import someGlobalClass

def someFunction:
initGlobalModule()
someGlobalClass.conn(qry)

does not work since someGlobalClass has not been initialized, so I have to
do the following:

def someFunction:
initGlobalModule()

from GlobalModules.someGlobalClass import someGlobalClass
someGlobalClass.conn(qry)

Somehow I like all my import at the top of the file and this does not seem
right. Is there some other way to do this?

Thanks,
 

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

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top