Patches item #1517586, was opened at 2006-07-05 15:31 Message generated for change (Comment added) made by gbrandl 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: Closed >Resolution: Rejected 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: Georg Brandl (gbrandl) Date: 2007-03-13 20:30 Message: Logged In: YES user_id=849994 Originator: NO Rejecting this for a number of reasons: Module-level globals to be set by the user of a module are bad 1) it is not obvious if it's not set directly before the getstatusoutput() call 2) it's completely confusing with threads 3) commands is quasi-deprecated in favor of subprocess ---------------------------------------------------------------------- Comment By: Bj�rn Lindqvist (sonderblade) Date: 2007-03-07 23: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