<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">from newMarketBot import NewMarketBot
import time
import queue
import threading
from ThreadMonitor import ThreadMonitor
from LoggingFormatter import logger
from AWSInit import createAWSSessions, createAWSSessionLimited
import Queues
from HelperFunctions import getWebshareProxies

all_sessions = createAWSSessions()
all_threads = []

def startScraper(filename: str):
    webshare_ips = getWebshareProxies()
    
    global all_threads
    # all_threads += Queues.startCsgofloatQueue(all_sessions=all_sessions, webshare_ips=webshare_ips)
    all_threads += Queues.startHandleListingsQueue(all_sessions=all_sessions, webshare_ips=webshare_ips)
    
    threadmonitor = ThreadMonitor(all_threads)
    threadmonitor_thread = threading.Thread(target=threadmonitor.list_running_threads)
    threadmonitor_thread.daemon = True
    threadmonitor_thread.name = "ActiveThreadsMonitor"
    all_threads.append(threadmonitor_thread)
    threadmonitor_thread.start()

    f = open(filename, "r")
    lines = f.readlines()
    f.close()

    lines = [x.strip() for x in lines]

    while True:
        high_or_low = "high"
        runThreads(
            lines,
            webshare_ips,
            high_or_low,
            all_sessions,
            Queues.listings_queue,
        )

        high_or_low = "low"
        runThreads(
            lines,
            webshare_ips,
            high_or_low,
            all_sessions,
            Queues.listings_queue,
        )
        time.sleep(120)


def runThreads(
    weapon_list: list,
    webshare_ips: list,
    high_or_low: str,
    all_sessions: list,
    listings_queue: queue.Queue,
):
    threads = []
    for line in weapon_list:
        m = NewMarketBot(
            high_or_low,
            str(line.rstrip()),
            webshare_ips,
            all_sessions,
            listings_queue,
        )
        t = threading.Thread(target=m.startBot)
        t.name = str(line).rstrip()
        t.daemon = True
        threads.append(t)
        all_threads.append(t)

    for thread in threads:
        thread.start()
        time.sleep(20)

    for thread in threads:
        thread.join()


if __name__ == "__main__":
    # Runs the scraper for all weapons
    logger.info("Start Program")
    startScraper(filename="list/tag_weapon_list.txt")
</pre></body></html>