Patches item #1517586, was opened at 2006-07-05 17:31 Message generated for change (Comment added) made by sonderblade You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1517586&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Library (Lib) Group: Python 2.4 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Brad Doctor (bdoctor) Assigned to: Nobody/Anonymous (nobody) Summary: Patch to commands.py to enable callback support Initial Comment: This is a patch to commands.py to enable callback support, which is very useful for long-running commands. Whenever there is stdout from the process the callback is fed whatever it got. Example usage: import commands cmd = 'top -b -n2' def fancy(out): print 'GOT(%s)' % out.strip() commands.cb = fancy (s,o) = commands.getstatusoutput(cmd) print 'OUTPUT (%s)' % o Please consider adding this. The existing API is not changed, however as you can see it is simple to use the callback. ---------------------------------------------------------------------- Comment By: Bj�rn Lindqvist (sonderblade) Date: 2007-03-08 00:29 Message: Logged In: YES user_id=51702 Originator: NO Your semantic for the cb name seems kind of arbitrary. Why is it called for each line of the output and only once with all the output. Plus, iterating through the output line for line can make it much slower than reading it all at once. Also, the next time you run getstatusoutput(), maybe even from another module, the callback will still be called. That could be unexpected. Plus commands is almost deprecated in favour of subprocess. I recommend rejecting this patch. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1517586&group_id=5470
_______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches