Helper to dump threads after a timeout. :param filename_template: A template filename, such as 'c:/temp/thread_dump_%s.txt', where the %s will be replaced by the time for the dump. :param timeout: The timeout (in seconds) for the dump. :param recurrent:
(filename_template, timeout, recurrent)
| 2812 | |
| 2813 | |
| 2814 | def start_dump_threads_thread(filename_template, timeout, recurrent): |
| 2815 | """ |
| 2816 | Helper to dump threads after a timeout. |
| 2817 | |
| 2818 | :param filename_template: |
| 2819 | A template filename, such as 'c:/temp/thread_dump_%s.txt', where the %s will |
| 2820 | be replaced by the time for the dump. |
| 2821 | :param timeout: |
| 2822 | The timeout (in seconds) for the dump. |
| 2823 | :param recurrent: |
| 2824 | If True we'll keep on doing thread dumps. |
| 2825 | """ |
| 2826 | assert filename_template.count("%s") == 1, "Expected one %%s to appear in: %s" % (filename_template,) |
| 2827 | |
| 2828 | def _threads_on_timeout(): |
| 2829 | try: |
| 2830 | while True: |
| 2831 | time.sleep(timeout) |
| 2832 | filename = filename_template % (time.time(),) |
| 2833 | try: |
| 2834 | os.makedirs(os.path.dirname(filename)) |
| 2835 | except Exception: |
| 2836 | pass |
| 2837 | with open(filename, "w") as stream: |
| 2838 | dump_threads(stream) |
| 2839 | if not recurrent: |
| 2840 | return |
| 2841 | except Exception: |
| 2842 | pydev_log.exception() |
| 2843 | |
| 2844 | t = threading.Thread(target=_threads_on_timeout) |
| 2845 | mark_as_pydevd_daemon_thread(t) |
| 2846 | t.start() |
| 2847 | |
| 2848 | |
| 2849 | def dump_threads(stream=None): |
nothing calls this directly
no test coverage detected