Ross McKerchar wrote: >I am having trouble connecting to an already running python com server. > > I have set CLSCTX_LOCAL_SERVER for my com object and I am using the > "GetObject" function in my vbscripts which connect to the com server. > > I have written a simple test server that behaves very similarly to my > real server (except the thread will actually do some work) > > ------------------------------------------------------------ > sleeper = threading.Thread(target=time.sleep,args=(20,)) > > class Test(object): > _public_methods_ = ["go"] > _reg_progid_ = "pythonutils.test" > _reg_clsid_ = "{57E47876-69CB-4822-92F1-B8D2716F54A4}" > _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER > > def go(self): > if sleeper.isAlive(): > return "Server is already running" > else: > sleeper.start() #start a thread that sleep for 20 seconds > return "Server NOT running" > ------------------------------------------------------------ > > Now, if I run two test clients it works fine if client #2 get's a > reference to my com server before client #1 stops running (i.e. client#1 > sleeps for 10 seconds and I run client#2, in a seperate process before > client#1 finishes). > > However, if I run my test clients sequentially each one creates a new > pythonw process. The old com server is definitely still running, > GetObject just decides to return a new one and I am unsure how the > change this behaviour. > > After browsing Mark's win32 book I've tried playing with the > _reg_threading_ but I'm not convinced it's relevant (I full admit I'm > dont understand com threading 100%). I also thought I was onto something > with the pythoncom.REGCLS_MULTIPLEUSE variable until I discovered that > this is used by default (in win32com.server.factory). > > Any suggestions would be much appreciated - even just some key phrases > that may help energise my search efforts...
An object needs to be registered in the Running Object Table (ROT) for this to work. See pythoncom.RegisterActiveObject. hth Roger _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32