fork vs threading.Thread

Chris Colbert sccolbert at gmail.com
Fri Feb 12 23:15:37 EST 2010


dont call the .run() method, call the .start() method which is defined the
Thread class (and should NOT be overridden).

tftpserv.start()

xmlserv.start()



On Fri, Feb 12, 2010 at 10:57 PM, Jordan Apgar <twistedphrame at gmail.com>wrote:

> I'm trying to run two servers in the same program at once.  Here are
> the two:
> class TftpServJ(Thread):
>    def __init__(self, ip, root, port=69, debug = False ):
>        Thread.__init__(self)
>        setup stuff here
>
>    def run(self):
>        try:
>            self.server.listen(self.ip, self.port)
>        except KeyboardInterrupt:
>            pass
>
> and
> class XMLServer(Thread):
>    def __init__(self, host, port, hostid, rsa_key):
>        Thread.__init__(self)
>         setup stuff
>
>    def run(self):
>        self.server.serve_forever()
>
>
> I call them as:
> tftpserv = TftpServJ(host, "/home/twistedphrame/Desktop/xmlrpc_server/
> server")
> tftpserv.run()
> xmlserv = XMLServer(host, port, HostID, key)
> xmlserv.run()
>
>
> it seems that tftpserv runs but wont go on to spawn xmlserv as well.
> do I need to fork if I want both these to run at the same time?  It
> was my impression that by using Thread execution in the main program
> would continue.
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100212/bc15c312/attachment-0001.html>


More information about the Python-list mailing list