I knew this was a basic python question :)) Thanks again. Pascal -----Message d'origine----- De : Chris McDonough [mailto:chrism@plope.com] Envoyé : mardi 22 février 2005 21:45 À : Pascal Peregrina Cc : ''zope@zope.org' ' Objet : RE: [Zope] Zope and threads. On Tue, 2005-02-22 at 15:22, Pascal Peregrina wrote:
Ok, so, this almost completely answers my question.
Let me tell you more about what I am doing, because I agree that my initial mail was not that clear. :)
I am trying to implement a ZeroConf browser (http://www.zeroconf.org/) in Zope to automatically get the network location of XML RPC services that my Zope objects talk to.
The ZMI part is easy. In my new product, I've got my object in the Control Panel, and it is ready to display whatever data I want (for example the list of discovered services).
The ZeroConf implementation itself has already been made by someone else (http://sourceforge.net/projects/pyzeroconf)
So I am just trying to plug pieces together now :)
From my product, I need to start a thread that will run the ZeroConf code, and ZeroConf data will then be accessible through a particular object of this code (the "listener" to be exact, as they call it in pyzeronf).
This thread should be started when Zope starts, so I guess I can put it in the __init__.py of my product.
I only got one issue : my product can be refreshed. So how can I ensure that the ZeroConf stuff won't be re-initialized if I refresh my product ? (ending with 2 threads, with one of the threads not being used). I know this is more a python related question, but I haven't found a precise answer on the net.
I'm not sure of how the internals of refresh work (I dont use it) but I suspect that if you do something like: import sys if not getattr(sys, 'ZEROCONF_STARTED'): .. start the thread .. sys.ZEROCONF_STARTED = 1 It will not spawn another thread. "sys" is just an example here, any module namespace should work (even __builtins__ probably). ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************