[Openstack] Swift nee st code weirdness

Pete Zaitcev zaitcev at redhat.com
Fri Apr 6 15:34:10 UTC 2012


On Fri, 6 Apr 2012 00:17:49 -0400
Andrew Clay Shafer <acs at parvuscaptus.com> wrote:

> What were you expecting/trying to do with the code change?

Here's a patch that hopefuly answers the question, although be warned
that it does not actually work even if the scope of parser is fixed
(it measures wrong thread):

--- a/bin/swift
+++ b/bin/swift
@@ -1889,7 +1889,7 @@ overridden with -A, -U, or -K.'''.strip('\n'))
     return options, args
 
 
-if __name__ == '__main__':
+def main():
     parser = OptionParser(version='%prog 1.0', usage='''
 Usage: %%prog <command> [options] [args]
 
@@ -1986,3 +1986,8 @@ Example:
         for thread in threading_enumerate():
             thread.abort = True
         raise
+
+if __name__ == '__main__':
+    # P3
+    import cProfile
+    cProfile.run('main()', "stprof")

-- Pete




More information about the Openstack mailing list