<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
Hi,<br>
<br>
thanks for your answer.<br>
<br>
I changed the localserver.py like you suggested by skipping to call
pythoncom.EnableQuitMessage().<br>
But what is the best way to close the pythonw process when desired? I
tried to call sys.exit() in the COM-Server Modul and got an error.<br>
<br>
A patch to specify a custom driver program would be to insert a
registration-related attribute on the COM Object (e.g.
_reg_custom_driver_) with the absolute path of the file of custom
driver program?<br>
Would this be sufficient when py2exe is used to compile the hole
server? <br>
<br>
What about an extension of the _reg_clsctx_ attribute to take a switch
like pythoncom.CLSCTX_LOCAL_SERVER_NO_QUIT?<br>
<br>
<br>
Ciao,<br>
Frank<br>
<br>
<a class="moz-txt-link-abbreviated" href="mailto:mhammond@skippinet.com.au">mhammond@skippinet.com.au</a>
wrote:<br>
<blockquote cite="mid03e201c514f8$615a25f0$140a0a0a@enfoldsystems.local" type="cite">
<pre wrap="">Currently there is no nice solution to your problem. I'm sure you
understand it is by design pythonw.exe closes when the last reference is
closed, and why your work-around is effective.
When hosted as a localserver, win32com\server\localserver.py is used as the
main program. This is configured in win32com\server\register.py, but there
is no facility for overriding this. I'd be happy to accept a patch which
allowed you to specify a custom driver program, and this would be free to
ignore the shutdown request (ie, simply not call
pythoncom.EnableQuitMessage())
Mark
</pre>
<blockquote type="cite">
<pre wrap="">-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:python-win32-bounces@python.org">python-win32-bounces@python.org</a>
[<a class="moz-txt-link-freetext" href="mailto:python-win32-bounces@python.org">mailto:python-win32-bounces@python.org</a>]On Behalf Of Frank Guenther
Sent: Thursday, 17 February 2005 11:22 PM
To: <a class="moz-txt-link-abbreviated" href="mailto:python-win32@python.org">python-win32@python.org</a>
Subject: [python-win32] keeping a COM server alive
Hi,
I posted this some days ago in comp.lang.python
<a class="moz-txt-link-rfc2396E" href="http://groups-beta.google.com/group/comp.lang.python"><http://groups-beta.google.com/group/comp.lang.python></a> but
didn't get a
real solution.
Perhaps someone here can help me.
I have implemented a local COM Server with win32com framework
where all
clients
use the same global object (test_obj). So far it works, but when the
last client is closed the gobal object is deleted because the
pythonw.exe is
closed. When I create a new client a new pythonw process is
started. I
need that the
new client gets the same global object. How can I prevent the
Python COM
enviornment (pythonw.exe) to close when no client exist. I
figured out a
workaround, but there must be real solution to the problem.
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 the local server 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)
_______________________________________________
Python-win32 mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Python-win32@python.org">Python-win32@python.org</a>
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/python-win32">http://mail.python.org/mailman/listinfo/python-win32</a>
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>