diff options
author | Rafael H. Schloming <rhs@apache.org> | 2009-06-11 18:37:51 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2009-06-11 18:37:51 +0000 |
commit | 2027d6f7239c73e2f1be327746544812f6171dde (patch) | |
tree | 76209d276809460c3658bad7da7045b6696270d4 /python/qpid/debug.py | |
parent | d04424dc3ecd88008b0b2c44fc5648a5b70647e5 (diff) | |
download | qpid-python-2027d6f7239c73e2f1be327746544812f6171dde.tar.gz |
cleand up and added license header
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@783868 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/debug.py')
-rw-r--r-- | python/qpid/debug.py | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/python/qpid/debug.py b/python/qpid/debug.py index 357340747f..b5dbd4d9d9 100644 --- a/python/qpid/debug.py +++ b/python/qpid/debug.py @@ -1,9 +1,25 @@ -import traceback, time, sys - -from threading import RLock - -def stackdump(*args): - print args +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +import threading, traceback, signal, sys, time + +def stackdump(sig, frm): code = [] for threadId, stack in sys._current_frames().items(): code.append("\n# ThreadID: %s" % threadId) @@ -13,28 +29,22 @@ def stackdump(*args): code.append(" %s" % (line.strip())) print "\n".join(code) -import signal signal.signal(signal.SIGQUIT, stackdump) -#out = open("/tmp/stacks.txt", "write") - class LoudLock: def __init__(self): - self.lock = RLock() + self.lock = threading.RLock() def acquire(self, blocking=1): - import threading while not self.lock.acquire(blocking=0): time.sleep(1) - print >> out, "TRYING" -# print self.lock._RLock__owner, threading._active -# stackdump() + print >> sys.out, "TRYING" traceback.print_stack(None, None, out) - print >> out, "TRYING" - print >> out, "ACQUIRED" + print >> sys.out, "TRYING" + print >> sys.out, "ACQUIRED" traceback.print_stack(None, None, out) - print >> out, "ACQUIRED" + print >> sys.out, "ACQUIRED" return True def _is_owned(self): |