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.CLSCT X_LOCAL_SERVER
_public_methods _ = ...
def __init__(self):
self.delegate=t est_obj
.....
.....
.....
#####Workaround to keep pythoncom alive
if not __name__=='__ma in__':
import win32com.client
dummy=win32com. client.Dispatch ("test.cl")
############### ############### ###############
if __name__=='__ma in__':
import win32com.server .register
win32com.server .register.UseCo mmandLine(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.CLSCT X_LOCAL_SERVER
_public_methods _ = ...
def __init__(self):
self.delegate=t est_obj
.....
.....
.....
#####Workaround to keep pythoncom alive
if not __name__=='__ma in__':
import win32com.client
dummy=win32com. client.Dispatch ("test.cl")
############### ############### ###############
if __name__=='__ma in__':
import win32com.server .register
win32com.server .register.UseCo mmandLine(test_ f, debug=0)