CoInitialize within a service?

10 views
Skip to first unread message

Chris Curvey

unread,
Dec 13, 2005, 1:39:15 PM12/13/05
to cherrypy-users
Has anyone had any luck using the CoInitialize recipe at
http://www.cherrypy.org/wiki/UsingCOMObjects when writing a Windows
Service with CherryPy? My first call to my server works fine, but the
second call says that "CoInitialize has not been called."

Chris Curvey

unread,
Dec 13, 2005, 4:05:52 PM12/13/05
to cherrypy-users
my solution was to put the calls to CoInitialize and CoUninitialize in
the constructor and destructor for the root class. for example

import pythoncom

class HelloWorld:
def __init__(self):
pythoncom.CoInitialize()

def __del__(self):
pythoncom.CoUninitialize()

def index(self):
return "Hello World!"
index.exposed = True

For some reason, putting adding the functions to the threadStart and
ThreadStop lists did not work when I was running as a service (except
for the first hit).

Remi Delon

unread,
Dec 14, 2005, 7:13:34 AM12/14/05
to cherryp...@googlegroups.com

Which version of CP are you using ?
If you were using the latest trunk then there was a bug that caused
onStartThreadList to not always work (only on_start_thread_list always
worked). I just fixed it.

Remi.

Chris Curvey

unread,
Dec 14, 2005, 12:21:15 PM12/14/05
to cherrypy-users
I was using CP 2.1.0 from sourceforge. If your fix is in Subversion,
I'll see if I can grab a copy this week and try it. Thanks!

Reply all
Reply to author
Forward
0 new messages