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)
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)