Mailing List Archive

calldll windll instantiation
Need some help.
I think?(scarry moment)? that I need to create more that one instance of a
dll.

1. Can this be done?
2. Is my sample even close?



"""gm_class quick wrapper of dll functions"""

import windll
import time

class test:

def __init__(self):
self.gm=windll.module('GM4S32')

def load_bde(self, SysDir='c:\\program files\\goldmine',
GoldDir='c:\\program files\\goldmine\\gmbase',
CommonDir='c:\\program files\\goldmine\\demo',
User='PERACLES',
Password=''):
start=time.time()
(SysDir, GoldDir, CommonDir,
User, Password)=map(windll.cstring,(SysDir, GoldDir, CommonDir,
User, Password))
return (self.gm.GMW_LoadBDE(SysDir, GoldDir, CommonDir, User,
Password), "Startup Time: " + str(time.time()-start))

def unload_bde(self):
return self.gm.GMW_UnloadBDE()

...other defs...


>>> import gm_class
>>> a=gm_class.test()
>>> b=gm_class.test()
>>> a
<gm_class.test instance at 856fd0>
>>> b
<gm_class.test instance at 85b140>
>>> a.gm
<win32 module 'GM4S32' (0 functions)>
>>> b.gm
<win32 module 'GM4S32' (0 functions)>
>>> a.load_bde() # This works
(1, 'Startup Time: 0.490000009537')
>>> a.gm
<win32 module 'GM4S32' (1 functions)>
>>> b.gm
<win32 module 'GM4S32' (1 functions)>
>>> b.load_bde() # This fails but should work ;-(
(0, 'Startup Time: 0.0')
>>> a.gm
<win32 module 'GM4S32' (1 functions)>
>>> b.gm
<win32 module 'GM4S32' (1 functions)>
>>> a.gm==b.gm # Don't know if this is correct
1
>>> a==b
0
>>>
>>> gm_class.windll.dump_module_info()
--------------------
WINDLL Function Call Stats:
--- <win32 module 'GM4S32' (1 functions)> ---
2 GMW_LoadBDE
>>>
calldll windll instantiation [ In reply to ]
Need some help.
I think?(scarry moment)? that I need to create more that one instance of a
dll.

1. Can this be done?
2. Is my sample even close?



"""gm_class quick wrapper of dll functions"""

import windll
import time

class test:

def __init__(self):
self.gm=windll.module('GM4S32')

def load_bde(self, SysDir='c:\\program files\\goldmine',
GoldDir='c:\\program files\\goldmine\\gmbase',
CommonDir='c:\\program files\\goldmine\\demo',
User='PERACLES',
Password=''):
start=time.time()
(SysDir, GoldDir, CommonDir,
User, Password)=map(windll.cstring,(SysDir, GoldDir, CommonDir,
User, Password))
return (self.gm.GMW_LoadBDE(SysDir, GoldDir, CommonDir, User,
Password), "Startup Time: " + str(time.time()-start))

def unload_bde(self):
return self.gm.GMW_UnloadBDE()

...other defs...


>>> import gm_class
>>> a=gm_class.test()
>>> b=gm_class.test()
>>> a
<gm_class.test instance at 856fd0>
>>> b
<gm_class.test instance at 85b140>
>>> a.gm
<win32 module 'GM4S32' (0 functions)>
>>> b.gm
<win32 module 'GM4S32' (0 functions)>
>>> a.load_bde() # This works
(1, 'Startup Time: 0.490000009537')
>>> a.gm
<win32 module 'GM4S32' (1 functions)>
>>> b.gm
<win32 module 'GM4S32' (1 functions)>
>>> b.load_bde() # This fails but should work ;-(
(0, 'Startup Time: 0.0')
>>> a.gm
<win32 module 'GM4S32' (1 functions)>
>>> b.gm
<win32 module 'GM4S32' (1 functions)>
>>> a.gm==b.gm # Don't know if this is correct
1
>>> a==b
0
>>>
>>> gm_class.windll.dump_module_info()
--------------------
WINDLL Function Call Stats:
--- <win32 module 'GM4S32' (1 functions)> ---
2 GMW_LoadBDE
>>>
calldll windll instantiation [ In reply to ]
Karl & Mel ask:

> Need some help.
> I think?(scarry moment)? that I need to create more that one
> instance of a dll.
>
> 1. Can this be done?

Nope. Perhaps if you made a second copy (of the dll file) and gave it
a different name. Or perhaps the dll uses thread local storage, and
if you attach from different threads it will act like each thread has
its own copy. But I doubt it.

Different processes will get different copies, so maybe you could use
IPC between 2 python scripts...


- Gordon