-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed1e6ab
commit 210c4a3
Showing
3 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ | |
@email: [email protected] | ||
""" | ||
|
||
from threading import Thread | ||
|
||
import feapder.setting as setting | ||
import feapder.utils.tools as tools | ||
from feapder.buffer.item_buffer import ItemBuffer | ||
|
@@ -20,9 +18,10 @@ | |
from feapder.network.request import Request | ||
from feapder.utils import metrics | ||
from feapder.utils.log import log | ||
from feapder.utils.tail_thread import TailThread | ||
|
||
|
||
class AirSpider(BaseParser, Thread): | ||
class AirSpider(BaseParser, TailThread): | ||
__custom_setting__ = {} | ||
|
||
def __init__(self, thread_count=None): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on 2024/3/19 20:00 | ||
--------- | ||
@summary: | ||
--------- | ||
@author: Boris | ||
@email: [email protected] | ||
""" | ||
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() |