Skip to content

Commit

Permalink
used module
Browse files Browse the repository at this point in the history
  • Loading branch information
DWAA1660 committed Nov 12, 2023
1 parent ba9ca54 commit 18f10a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 40 deletions.
39 changes: 1 addition & 38 deletions concurrency.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,12 @@
from threadedreturn import ThreadWithReturnValue
from threading import Thread

'''
concurrency.py
Code here is designed to speed up certain processes that might take too long
ThreadWithReturnValue is used on functions that returns a certain variable
'''
class ThreadWithReturnValue(Thread):
def __init__(self, group=None, target=None, name=None,
args=(), kwargs={}, Verbose=None):
"""
Initialize a ThreadWithReturnValue instance.
Parameters:
- group: Thread group (not commonly used, defaults to None).
- target: The callable object to be invoked when the thread starts.
- name: The thread name.
- args: A tuple of positional arguments to pass to the target function.
- kwargs: A dictionary of keyword arguments to pass to the target function.
- Verbose: Verbose level (not commonly used, defaults to None).
"""
Thread.__init__(self, group, target, name, args, kwargs)
self._return = None

def run(self):
"""
Override the run method to execute the target function and store its return value.
"""
if self._target is not None:
self._return = self._target(*self._args,
**self._kwargs)
def join(self, *args):
"""
Override the join method to return the stored return value after joining the thread.
Parameters:
- args: Additional arguments to pass to the join method (not commonly used).
Returns:
- object: The return value of the target function executed by the thread.
"""
Thread.join(self, *args)
return self._return

def cloudf_doms(DOMAINS, CLOUDFLARE) -> list:
"""
Retrieve all subdomains for a list of domains using Cloudflare API.
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from data_sql import *
from discord import get_github_username, send_discord_message
from concurrency import *

from threadedreturn import ThreadWithReturnValue
#Sql Wrapper
database = dataSQL(dbfile="database.db")
#Flask App
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Flask==3.0.0
Requests==2.31.0
GitHub-Flask
authlib
authlib
threadedreturn

0 comments on commit 18f10a7

Please sign in to comment.