New to threading. Right idea???

Karl Putland llwo at dbtech.net
Mon Jun 14 08:07:15 EDT 1999


Thanks David.
>
> If you must call EXPENSIVE for each directory, then you must -- I don't
> think there's any way around that.  Loading the same DLL multiple times
> won't help if you have to call EXPENSIVE for each (especially if
> unexpensive is, well, unexpensive =).  If EXPENSIVE is VERY_EXPENSIVE,
> where VERY_EXPENSIVE >> cost of loading the DLL, then even a fork()
> wouldn't help much, even if it were available on your OS.
>
> --david ascher

I experimented with creating a copy of the dll with a diferent name and
loading it.  This worked.  I could call EXPENSIVE for the dll and the
copy_of_dll and both succeed.

The other interesting part of this is that EXPENSIVE executes over twenty
times faster the second time around.  That is if dll and copy_of_dll are
both loaded, calling dll.EXPENSIVE takes between 1.5 and 4.8 seconds, then
calling copy_of_dll.EXPENSIVE takes .022 - .22.  EXPENSIVE is really called
load_bde().

I guess that I will just manage the files to load one ofr more copies of the
dll since that seems to work like I need it to.

>>> from gm4s32 import *
>>> load_bde()
(1, 'Startup Time: 0.99999997139')
>>> copy_load_bde()
(1, 'Startup Time: 0.0499999523163')
>>>


***snippet from module gm4s32.py***
import windll
import time
import os
import string
from types import *

gm=windll.module('GM4S32')
gma=windll.module('GM4S3a')

##if raw_input('(W)ork or (H)ome: ')=='W':
##    SysDir='G:\\'
##    GoldDir='G:\\'
##    CommonDir='g:\\merged'
##    User='MASTER'
##    Password='ACCESS'
##else:

SysDir='d:\\goldmine'
GoldDir='d:\\goldmine\\gmbase'
CommonDir='d:\\goldmine\\demo'
User='KARL'
Password='KAPPASIG'

def load_bde(sysDir='',
      goldDir='',
      commonDir='',
      user='',
      password=''):

    global SysDir, GoldDir, CommonDir, User, Password

    if not sysDir: sysDir=SysDir
    if not goldDir: goldDir=GoldDir
    if not commonDir: commonDir=CommonDir
    if not user: user=User
    if not password: password=Password

    SysDir=sysDir
    GoldDir=goldDir
    CommonDir=commonDir
    User=user
    Password=password

    start=time.time()
    (sysDir, goldDir, commonDir,
     user, password)=map(windll.cstring,(sysDir, goldDir, commonDir,
        user, password))
    return (gm.GMW_LoadBDE(sysDir, goldDir, commonDir, user, password),
"Startup Time: " + str(time.time()-start))

def unload_bde():
    return gm.GMW_UnloadBDE()

def copy_load_bde(sysDir='',
      goldDir='',
      commonDir='',
      user='',
      password=''):

    global SysDir, GoldDir, CommonDir, User, Password

    if not sysDir: sysDir=SysDir
    if not goldDir: goldDir=GoldDir
    if not commonDir: commonDir=CommonDir
    if not user: user=User
    if not password: password=Password

    SysDir=sysDir
    GoldDir=goldDir
    CommonDir=commonDir
    User=user
    Password=password

    start=time.time()
    (sysDir, goldDir, commonDir,
     user, password)=map(windll.cstring,(sysDir, goldDir, commonDir,
        user, password))
    return (gma.GMW_LoadBDE(sysDir, goldDir, commonDir, user, password),
"Startup Time: " + str(time.time()-start))

def copy_unload_bde():
    return gma.GMW_UnloadBDE()






More information about the Python-list mailing list