Exemple #1
0
def test_dump_traceback():
    started = threading.Event()
    stop = threading.Event()

    class Thread(threading.Thread):
        def run(self):
            started.set()
            assert_true(stop.wait(1.0))

    thread = Thread(name='thread_util_test thread')
    thread.start()
    thread_ident = str(thread.ident)

    header = 'Thread thread_util_test thread %s' % thread_ident

    try:
        assert_true(started.wait(1.0))

        out = StringIO.StringIO()
        dump_traceback(file=out)

        assert_true(header in out.getvalue())

        out = StringIO.StringIO()
        dump_traceback(file=out, all_threads=False)

        assert_true(header not in out.getvalue())
    finally:
        stop.set()
        thread.join()
Exemple #2
0
def test_dump_traceback():
  started = threading.Event()
  stopped = threading.Event()

  class Thread(threading.Thread):
    def run(self):
      started.set()
      stopped.wait(10.0)
      assert_true(stopped.is_set())

  thread = Thread(name='thread_util_test thread')
  thread.start()
  thread_ident = str(thread.ident)

  header = 'Thread thread_util_test thread %s' % thread_ident

  try:
    started.wait(10.0)
    assert_true(started.is_set())

    out = StringIO.StringIO()
    dump_traceback(file=out)

    assert_true(header in out.getvalue())

    out = StringIO.StringIO()
    dump_traceback(file=out, all_threads=False)

    assert_true(header not in out.getvalue())
  finally:
    stopped.set()
    thread.join()
Exemple #3
0
def threads(request):
    """Dumps out server threads. Useful for debugging."""
    out = StringIO.StringIO()
    dump_traceback(file=out)

    if not request.user.is_superuser:
        return HttpResponse(_("You must be a superuser."))

    return HttpResponse(out.getvalue(), content_type="text/plain")
Exemple #4
0
def threads(request):
    """Dumps out server threads.  Useful for debugging."""
    if not request.user.is_superuser:
        return HttpResponse(_("You must be a superuser."))

    out = StringIO.StringIO()
    dump_traceback(file=out)

    return HttpResponse(out.getvalue(), content_type="text/plain")
Exemple #5
0
def threads(request):
  """Dumps out server threads. Useful for debugging."""
  out = string_io()
  dump_traceback(file=out)

  if request.is_ajax():
    return HttpResponse(out.getvalue(), content_type="text/plain")
  else:
    return render("threads.mako", request, {'text': out.getvalue(), 'is_embeddable': request.GET.get('is_embeddable', False)})
Exemple #6
0
def threads(request):
  """Dumps out server threads. Useful for debugging."""
  out = StringIO.StringIO()
  dump_traceback(file=out)

  if not is_admin(request.user):
    return HttpResponse(_("You must be a superuser."))

  if request.is_ajax():
    return HttpResponse(out.getvalue(), content_type="text/plain")
  else:
    return render("threads.mako", request, {'text': out.getvalue(), 'is_embeddable': request.GET.get('is_embeddable', False)})
Exemple #7
0
def dump_threads_on_sigquit(signum, frame):
    """Dump out the threads to stderr"""
    dump_traceback()
Exemple #8
0
def dump_threads_on_sigquit(signum, frame):
  """Dump out the threads to stderr"""
  dump_traceback()