threads and COM
Darrell
news at dorb.com
Wed Sep 1 21:13:08 EDT 1999
----- Original Message -----
From: Mark Hammond
To: 'Darrell'
Sent: Wednesday, September 01, 1999 8:50 PM
Subject: RE: hummm
from threading import Thread
import pythoncom
from uuid import WGIDGEN
def uuid_gen():
pythoncom.CoInitialize()
x=WGIDGEN()
y=x.GenWGID()
print "UUID IS ", y
Try adding these lines:
x = y = None
pythoncom.CoUninitialize()
And this should hopefully stop the problem:
t1 = Thread(target=uuid_gen)
t1.start()
Except that your app will try and exit immediately after starting the new
thread. Add a "t1.join()" to ensure the thread has finished before the app
terminates.
Mark.
--
--Darrell
Darrell <news at dorb.com> wrote in message
news:uQjz3.622$X5.26032 at typhoon.nyroc.rr.com...
> This program crashes python.
> And removing the CoInitialize() gives
> com_error: (-2147221008, 'CoInitialize has not been called.', None, None)
> Other combinations include "tstate mix-up" errors.
>
> WGIDGEN is setup for apartment threading.
> Any ideas ?
> Don't tell me the main thread must be owned by COM.
>
> from threading import Thread
> import pythoncom
> from uuid import WGIDGEN
>
> def uuid_gen():
> pythoncom.CoInitialize()
> x=WGIDGEN()
> y=x.GenWGID()
> print "UUID IS ", y
>
> t1 = Thread(target=uuid_gen)
> t1.start()
>
> --
> --Darrell
>
>
More information about the Python-list
mailing list