spamCheck #1

Merged
nolan merged 4 commits from spamCheck into master 2025-10-07 18:35:43 -04:00
2 changed files with 38 additions and 1 deletions
Showing only changes of commit 82999e37f8 - Show all commits

35
TimeWaster.py Normal file
View File

@ -0,0 +1,35 @@
import time, uuid, signal, random, os
class TimeWaster:
def __init__(self):
self.running = True
self.jobs: dict = {}
def handleNewJob(self):
jobId: uuid.UUID = uuid.uuid4()
self.jobs[jobId] = "exists i guess"
def handleCancelJob(self):
pass
def quit(self):
self.running = False
def main(self):
while self.running:
if len(self.jobs) == 0:
time.sleep(0.01)
else:
uuid = self.jobs.keys[0]
job = self.jobs[uuid]
time.sleep(random.randrange(1, 10) / 10)
result: JobResult = JobResult(uuid, "done i guess")
os.write(1, result)
class JobResult:
def __init__(self, uuid, result) -> None:
self.uuid = uuid
self.result = result
if __name__ == "__main__":
TimeWaster().main()

View File

@ -1,5 +1,5 @@
from websockets import *
import asyncio, json, signal, sys, time, random
import asyncio, json, signal, sys, time, random, subprocess, os
class WebSocketServer:
server: Server = None
@ -17,6 +17,8 @@ class WebSocketServer:
async def handleConnection(self, connection: ServerConnection) -> None: #TODO: Make this actually do something
print(f"{connection.remote_address} Connected")
stdio: tuple(int, int) = os.pipe2()
worker: subprocess.Popen = subprocess.Popen(["python3", "TimeWaster.py"], stdin=stdio[0], stdout=stdio[1])
connected: bool = True
task: asyncio.Task = None
while (connected):