Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions user_scanner/core/engine.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import asyncio
import inspect
import concurrent.futures

from typing import List
from types import ModuleType

from user_scanner.core.result import Result
from user_scanner.core.helpers import find_category, get_site_name, load_modules, load_categories

_shared_executor = concurrent.futures.ThreadPoolExecutor(max_workers=60)

async def check(module: ModuleType, target: str) -> Result:
module_name = module.__name__.split(".")[-1]
Expand All @@ -27,7 +29,8 @@ async def check(module: ModuleType, target: str) -> Result:
if inspect.iscoroutinefunction(func):
result = await func(target)
else:
result = await asyncio.to_thread(func, target)
loop = asyncio.get_running_loop()
result = await loop.run_in_executor(_shared_executor, func, target)
except Exception as e:
result = Result.error(e)

Expand Down Expand Up @@ -65,3 +68,4 @@ async def check_all(target: str, is_email: bool = True) -> List[Result]:
results.extend(sublist)

return results

Loading