[Pythonmac-SIG] Threading and FrameWork.Application

Sean Hummel seanh@real.com
Thu, 4 Apr 2002 17:22:22 -0800 (PST)


Well the first thing I would do, would be to check the version of
threading for Python, you have compiled in.  If the the Threading module
is using the built-in thread model, (weren't they called
micro-threads?,) then this would be something I could really see
happening.  If you use Apple's Development  tools, (I can't remember the
name of the specific tool,) there is a tool which lets you look at the
threads running in a current task.  You should use that and see what's
running.

On Fri, 5 Apr 2002, Pieter Claerhout wrote:

> Hi all,
> 
> I'm trying to wrap the module xmlrpclibServer, which is downloadable from
> http://mrken.net/code/xml-rpc/xmlrpcServer.py. The most simple thing of
> course is to just use the BuildApplication utility to make a standalone
> version of it, and you're done.
> 
> Unfortunately, I want to add an about box, and I also want to add the menu
> File with the option Quit. I got so far that I came up with the following
> piece of code:
> 
> <code>
> import threading
> import FrameWork
> import EasyDialogs
> import xmlrpcServer
> 
> class DaemonMac(FrameWork.Application):
> 
>     def __init__(self):
>         FrameWork.Application.__init__(self)
>         self.MyRPCServer = threading.Thread(target=xmlrpcServer._main)
>         self.MyRPCServer.start()
>         self.mainloop()
> 
>     def makeusermenus(self):
>         self.filemenu = m = FrameWork.Menu(self.menubar, "File")
>         self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
> 
>     def quit(self, *args):
>         self._quit()
> 
> if __name__ == '__main__':
>     DaemonMac()
> </code>
> 
> I tried to use the threading module to start the XML RPC server in a
> different thread (xmlrpcServer itself also is a threaded piece of code), but
> that seems to conflict with the mainloop. If you start this application, it
> starts the thread, starts the mainloop and stays in there, once you finish
> the mainloop, the thread continues.
> 
> Is there an easy way to wrap Python scripts like this in a macintosh
> application? If not, what options should I look at? If so, how should I do
> it? My guess is that I should hack it somewhere in the mainloop, but I'm not
> sure how and I don't know where I should start looking.
> 
> Hope someone can help here.
> 
> Thanks,
> 
> 
> 
> Pieter
> 
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> 
>