zoukankan      html  css  js  c++  java
  • python下的jstack

    背景

    • python 多进程任务,卡在某个地方没有继续执行也没有报出异常,进程被hang住
    • 日志没有捕获到相关信息,需要知道进程阻塞在哪里,为什么阻塞
    • jvm提供了jstack、jmap类工具进行性能分析,python有没有类似于pystack的工具
    • python jstack pystack 调试工具
    • 依赖gdb
    • 结论:http接口访问忘记设置超时,导致接口响应缓慢情况下任务死等。

    安装

    yum install gdb
    pip install pystack-debugger
    

    内网安装

    pip download pystack-debugger
    wget -c -t 10 10.222.77.121:12306/pystack_debugger-0.9.0-py2-none-any.whl
    wget -c -t 10 10.222.77.121:12306/click-5.1-py2.py3-none-any.whl
    pip install ./click-5.1-py2.py3-none-any.whl
    pip install ./pystack_debugger-0.9.0-py2-none-any.whl
    

    pystack 使用(其他作业,背景中debug作业信息已丢失)

    • threads
    pystack 22374
    
    pystack 22374
    Dumping Threads....
    
    
      File "/usr/lib64/python2.7/threading.py", line 784, in __bootstrap
        self.__bootstrap_inner()
      File "/usr/lib64/python2.7/threading.py", line 811, in __bootstrap_inner
        self.run()
      File "/usr/lib64/python2.7/threading.py", line 764, in run
        self.__target(*self.__args, **self.__kwargs)
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/_waic_base_job_definition.py", line 157, in wait
        time.sleep(self.watch_dog_duration)
    
    ---------------
    
      File "/data0/control_center/weibox/yarn-weibox/tools/waic_weibox_submit.py", line 17, in <module>
        kimy.submit()
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/_waic_base_job_definition.py", line 175, in submit
        self.job_execute()
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/_waic_base_job_definition.py", line 521, in job_execute
        (response_code, response_out, response_err) = helpers.run_shell("bash " + self.weibox_submit_name)
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/helpers.py", line 218, in run_shell
        stdout, stderr = p.communicate()
      File "/usr/lib64/python2.7/subprocess.py", line 800, in communicate
        return self._communicate(input)
      File "/usr/lib64/python2.7/subprocess.py", line 1401, in _communicate
        stdout, stderr = self._communicate_with_poll(input)
      File "/usr/lib64/python2.7/subprocess.py", line 1455, in _communicate_with_poll
        ready = poller.poll()
      File "<string>", line 1, in <module>
      File "<string>", line 1, in <module>
    
    

    • greenlet
    pystack 22374 --include-greenlet
    
    pystack 22374 --include-greenlet
    Dumping Threads....
    
    
      File "/usr/lib64/python2.7/threading.py", line 784, in __bootstrap
        self.__bootstrap_inner()
      File "/usr/lib64/python2.7/threading.py", line 811, in __bootstrap_inner
        self.run()
      File "/usr/lib64/python2.7/threading.py", line 764, in run
        self.__target(*self.__args, **self.__kwargs)
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/_waic_base_job_definition.py", line 157, in wait
        time.sleep(self.watch_dog_duration)
    
    ---------------
    
      File "/data0/control_center/weibox/yarn-weibox/tools/waic_weibox_submit.py", line 17, in <module>
        kimy.submit()
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/_waic_base_job_definition.py", line 175, in submit
        self.job_execute()
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/_waic_base_job_definition.py", line 521, in job_execute
        (response_code, response_out, response_err) = helpers.run_shell("bash " + self.weibox_submit_name)
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/helpers.py", line 218, in run_shell
        stdout, stderr = p.communicate()
      File "/usr/lib64/python2.7/subprocess.py", line 800, in communicate
        return self._communicate(input)
      File "/usr/lib64/python2.7/subprocess.py", line 1401, in _communicate
        stdout, stderr = self._communicate_with_poll(input)
      File "/usr/lib64/python2.7/subprocess.py", line 1455, in _communicate_with_poll
        ready = poller.poll()
      File "<string>", line 1, in <module>
      File "<string>", line 1, in <module>
    
    Dumping Greenlets....
    
    
      File "/data0/control_center/weibox/yarn-weibox/tools/waic_weibox_submit.py", line 17, in <module>
        kimy.submit()
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/_waic_base_job_definition.py", line 175, in submit
        self.job_execute()
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/_waic_base_job_definition.py", line 521, in job_execute
        (response_code, response_out, response_err) = helpers.run_shell("bash " + self.weibox_submit_name)
      File "/mnt/disk1/control_center/weibox/yarn-component/tools/utils/helpers.py", line 218, in run_shell
        stdout, stderr = p.communicate()
      File "/usr/lib64/python2.7/subprocess.py", line 800, in communicate
        return self._communicate(input)
      File "/usr/lib64/python2.7/subprocess.py", line 1401, in _communicate
        stdout, stderr = self._communicate_with_poll(input)
      File "/usr/lib64/python2.7/subprocess.py", line 1455, in _communicate_with_poll
        ready = poller.poll()
      File "<string>", line 1, in <module>
      File "<string>", line 1, in <module>
      File "<string>", line 1, in <genexpr>
    
    
  • 相关阅读:
    UVa 10088 (Pick定理) Trees on My Island
    LA 3295 (计数 容斥原理) Counting Triangles
    LA 5846 (计数) Neon Sign
    java是什么?软帝学院告诉你学Java能做什么?Java有什么特性?
    【软帝学院】一套好的java基础教学视频需要哪些有哪些内容
    推荐五个java基础学习网站,小白必备
    学习java设计模式有用吗?懂这六个原则,编程更轻松
    Java是什么?只需5分钟,了解java必须要知道的知识点
    软帝学院:自学java到底难不难?做好这几步,少走3年弯路
    软帝学院:java开发程序很难吗?学会这十步,5分钟搞定一个程序
  • 原文地址:https://www.cnblogs.com/suanec/p/12697177.html
Copyright © 2011-2022 走看看