keep a local COM Server alive

X

xeoicq

I wrote a COM server in Python where all the clients use the same
global object(test_obj). So far it works, but when the last client is
closed the Python COM enviornment is closed and the global object is
lost. How can I prevent that?
I need that new clients use the same global object and not a new
created one. I figured out a workaround, but there must be another
solution.

The code looks like:

class test:
.....

test_obj=test()

class test_f:
_reg_clsid_ = ...
_reg_progid_ = "test.cl"
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
_public_methods_ = ...


def __init__(self):
self.delegate=test_obj
.....
.....
.....

#####Workaround to keep pythoncom alive
if not __name__=='__main__':
import win32com.client
dummy=win32com.client.Dispatch("test.cl")
#############################################

if __name__=='__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(test_f, debug=0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top