mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 19:24:23 +00:00
First version to merge
This commit is contained in:
33
core/base.py
33
core/base.py
@@ -452,6 +452,39 @@ class Base:
|
||||
except AssertionError as ae:
|
||||
self.logs.error(f'{ae}')
|
||||
|
||||
def is_thread_alive(self, thread_name: str) -> bool:
|
||||
"""Check if the thread is still running! using the is_alive method of Threads.
|
||||
|
||||
Args:
|
||||
thread_name (str): The thread name
|
||||
|
||||
Returns:
|
||||
bool: True if is alive
|
||||
"""
|
||||
for thread in self.running_threads:
|
||||
if thread.name.lower() == thread_name.lower():
|
||||
if thread.is_alive():
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
def is_thread_exist(self, thread_name: str) -> bool:
|
||||
"""Check if the thread exist in the local var (running_threads)
|
||||
|
||||
Args:
|
||||
thread_name (str): The thread name
|
||||
|
||||
Returns:
|
||||
bool: True if the thread exist
|
||||
"""
|
||||
for thread in self.running_threads:
|
||||
if thread.name.lower() == thread_name.lower():
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def thread_count(self, thread_name: str) -> int:
|
||||
"""This method return the number of existing threads
|
||||
currently running or not running
|
||||
|
||||
Reference in New Issue
Block a user