asyncore loop and cmdloop problem

Giampaolo Rodolà g.rodola at gmail.com
Tue May 25 06:03:22 EDT 2010


2010/5/25 Michele Simionato <michele.simionato at gmail.com>:
> On May 25, 10:42 am, "kak... at gmail.com" <kak... at gmail.com> wrote:
>> Hi to all,
>> i'm creating a command line application using asyncore and cmd. At
>>
>> if __name__ == '__main__':
>>     import socket
>>
>>     args = sys.argv[1:]
>>     if not args:
>>         print "Usage: %s querystring" % sys.argv[0]
>>         sys.exit(0)
>>
>>     address = ('localhost', 0) # let the kernel give us a port
>>     server = EchoServer(address)
>>     ip, port = server.address # find out what port we were given
>>
>>     asyncore.loop()
>>     CmdClass().cmdloop()
>>
>> what i want is that the above commands asyncore.loop() and
>> CmdClass().cmdloop()
>> running at the same time. Meaning that while the application is in cmd
>> mode
>> with the cmdloop(), it is still able to listen for incoming messages?
>> What should i do?
>>
>> thanks in advance
>> A.K.
>
> cmd.Cmd is blocking, so the only way it to run the cmdloop in a
> separated thread. Once for fun
> I rewrote the cmd module to be non-blocking but if you want to stick
> with the standard library you need to use a thread.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Too bad cmdloop() doesn't provide an argument to return immediately.
Why don't you submit this patch on the bug tracker?


--- Giampaolo
http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil



More information about the Python-list mailing list