Re: asyncore loop and cmdloop problem
On May 26, 2:03 am, exar...@twistedmatrix.com wrote: On 04:31 pm, kak...@gmail.com wrote: On May 25, 5:47 pm, kak...@gmail.com kak...@gmail.com wrote: On May 25, 5:23 pm, Michele Simionato michele.simion...@gmail.com wrote: On May 25, 2:56 pm, kak...@gmail.com kak...@gmail.com wrote: Could you please provide me with a simple example how to do this with threads. I don't know where to put the cmdloop(). Please help, i' m so confused! Thank you What are you trying to do? Do you really need to use the standard library? Likely what you want to accomplish is already implemented in Twisted; I remember there was something like that in their examples directory. Thank you, and sorry for the mistake i did before with my post. Antonis hi again. i installed twisted, but since i m not familiar with it, do you remember which example you have in mind? What i want to accomplish is something like asterisk. while you send commands from the asterisk cli, at the same time the underlying protocol sends you notifications to the console. without exiting the application. thanks You can find a couple simple examples here: http://twistedmatrix.com/documents/current/core/examples/ Search for stdin and stdio. Jean-Paul Thank you so much, i'll check them!!! Antonis -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
On May 25, 10:42 am, kak...@gmail.com kak...@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
Re: asyncore loop and cmdloop problem
On May 25, 4:55 am, Michele Simionato michele.simion...@gmail.com wrote: On May 25, 10:42 am, kak...@gmail.com kak...@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. Thank you so much. Is there a way that i can find that version of cmd? Antonis -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
2010/5/25 Michele Simionato michele.simion...@gmail.com: On May 25, 10:42 am, kak...@gmail.com kak...@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 -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
On May 25, 12:03 pm, Giampaolo Rodolà g.rod...@gmail.com wrote: Too bad cmdloop() doesn't provide an argument to return immediately. Why don't you submit this patch on the bug tracker? --- Giampaolohttp://code.google.com/p/pyftpdlibhttp://code.google.com/p/psutil Because it is not a bug, cmd was designed to be blocking. It would be a feature request. I wrote a cmd2 module a few years ago, which was intended as a replacement for cmd with various additional features (including the non blocking behavior). We are using it in production, but I have never published it (I intended to but, you know, a days has only 24 hours ;) I should put together the code in a single file and publish it, but I cannot guarantee if and when I will have the time to do so. -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
2010/5/25 Michele Simionato michele.simion...@gmail.com: On May 25, 12:03 pm, Giampaolo Rodolà g.rod...@gmail.com wrote: Too bad cmdloop() doesn't provide an argument to return immediately. Why don't you submit this patch on the bug tracker? --- Giampaolohttp://code.google.com/p/pyftpdlibhttp://code.google.com/p/psutil Because it is not a bug, cmd was designed to be blocking. It would be a feature request. Sure, a feature request, but it would be nice to have anyway. =) The OP question shown how this can be desirable in certain circumstances.. --- Giampaolo http://code.google.com/p/pyftpdlib http://code.google.com/p/psutil -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
On May 25, 6:48 am, Giampaolo Rodolà g.rod...@gmail.com wrote: 2010/5/25 Michele Simionato michele.simion...@gmail.com: On May 25, 12:03 pm, Giampaolo Rodolà g.rod...@gmail.com wrote: Too bad cmdloop() doesn't provide an argument to return immediately. Why don't you submit this patch on the bug tracker? --- Giampaolohttp://code.google.com/p/pyftpdlibhttp://code.google.com/p/psutil Because it is not a bug, cmd was designed to be blocking. It would be a feature request. Sure, a feature request, but it would be nice to have anyway. =) The OP question shown how this can be desirable in certain circumstances.. --- Giampaolohttp://code.google.com/p/pyftpdlibhttp://code.google.com/p/psutil Could you please provide me with a simple example how to do this with threads. I don't know where to put the cmdloop(). Please help, i' m so confused! Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
On May 25, 2:56 pm, kak...@gmail.com kak...@gmail.com wrote: Could you please provide me with a simple example how to do this with threads. I don't know where to put the cmdloop(). Please help, i' m so confused! Thank you What are you trying to do? Do you really need to use the standard library? Likely what you want to accomplish is already implemented in Twisted; I remember there was something like that in their examples directory. -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
On May 25, 5:23 pm, Michele Simionato michele.simion...@gmail.com wrote: On May 25, 2:56 pm, kak...@gmail.com kak...@gmail.com wrote: Could you please provide me with a simple example how to do this with threads. I don't know where to put the cmdloop(). Please help, i' m so confused! Thank you What are you trying to do? Do you really need to use the standard library? Likely what you want to accomplish is already implemented in Twisted; I remember there was something like that in their examples directory. Thank you, and sorry for the mistake i did before with my post. Antonis -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
On May 25, 5:47 pm, kak...@gmail.com kak...@gmail.com wrote: On May 25, 5:23 pm, Michele Simionato michele.simion...@gmail.com wrote: On May 25, 2:56 pm, kak...@gmail.com kak...@gmail.com wrote: Could you please provide me with a simple example how to do this with threads. I don't know where to put the cmdloop(). Please help, i' m so confused! Thank you What are you trying to do? Do you really need to use the standard library? Likely what you want to accomplish is already implemented in Twisted; I remember there was something like that in their examples directory. Thank you, and sorry for the mistake i did before with my post. Antonis hi again. i installed twisted, but since i m not familiar with it, do you remember which example you have in mind? What i want to accomplish is something like asterisk. while you send commands from the asterisk cli, at the same time the underlying protocol sends you notifications to the console. without exiting the application. thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: asyncore loop and cmdloop problem
On 04:31 pm, kak...@gmail.com wrote: On May 25, 5:47�pm, kak...@gmail.com kak...@gmail.com wrote: On May 25, 5:23�pm, Michele Simionato michele.simion...@gmail.com wrote: On May 25, 2:56�pm, kak...@gmail.com kak...@gmail.com wrote: Could you please provide me with a simple example how to do this with threads. I don't know where to put the cmdloop(). Please help, i' m so confused! Thank you What are you trying to do? Do you really need to use the standard library? Likely what you want to accomplish is already implemented in Twisted; I remember there was something like that in their examples directory. Thank you, and sorry for the mistake i did before with my post. Antonis hi again. i installed twisted, but since i m not familiar with it, do you remember which example you have in mind? What i want to accomplish is something like asterisk. while you send commands from the asterisk cli, at the same time the underlying protocol sends you notifications to the console. without exiting the application. thanks You can find a couple simple examples here: http://twistedmatrix.com/documents/current/core/examples/ Search for stdin and stdio. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list