ctypes:Multiple library access problem

Massi massi_srb at msn.com
Thu May 6 04:22:54 EDT 2010


Hi everyone,

in my script I need to execute multiple separated loading of the same
dll library, in order to handle the internal variables with different
threads.
Consider the followin piece of code:

lib1 = cdll.LoadLibrary("MyLib.dll"))
lib2 = cdll.LoadLibrary("MyLib.dll"))

lib1.var1 = 0
lib2.var1 = 1

Now, if I print the value of lib1.var1 I get 1, that is lib1 and lib2
point to the same memory space. Is there a way to create "different
instances" of the same library? Or, alternatively, does it exist any
workaround to avoid lib1 and lib2 share the same memory space?

Thanks in advance.



More information about the Python-list mailing list