-
Notifications
You must be signed in to change notification settings - Fork 542
Expand file tree
/
Copy pathtail_thread.py
More file actions
33 lines (29 loc) · 796 Bytes
/
tail_thread.py
File metadata and controls
33 lines (29 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
"""
Created on 2024/3/19 20:00
---------
@summary:
---------
@author: Boris
@email: boris_liu@foxmail.com
"""
import sys
import threading
class TailThread(threading.Thread):
"""
所有子线程结束后,主线程才会退出
"""
def start(self) -> None:
"""
解决python3.12 RuntimeError: cannot join thread before it is started的报错
"""
super().start()
if sys.version_info.minor >= 12 and sys.version_info.major >= 3:
for thread in threading.enumerate():
if (
thread.daemon
or thread is threading.current_thread()
or not thread.is_alive()
):
continue
thread.join()