Ashley Wright
commited on
Commit
·
7ac68ef
1
Parent(s):
0972315
Add better messaging
Browse files- src/main.py +19 -1
src/main.py
CHANGED
@@ -12,21 +12,39 @@ SOCKET = "/sandbox/inferences.sock"
|
|
12 |
|
13 |
|
14 |
def main():
|
|
|
15 |
pipeline = load_pipeline()
|
16 |
|
|
|
|
|
17 |
with socket(AF_UNIX, SOCK_STREAM) as inference_socket:
|
18 |
inference_socket.bind(SOCKET)
|
19 |
|
20 |
chmod(SOCKET, 0o777)
|
21 |
|
22 |
inference_socket.listen(1)
|
|
|
|
|
|
|
23 |
connection, _ = inference_socket.accept()
|
24 |
|
|
|
|
|
25 |
with connection:
|
|
|
|
|
26 |
while True:
|
27 |
size = int.from_bytes(connection.recv(2), byteorder)
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
image = infer(request, pipeline)
|
32 |
|
|
|
12 |
|
13 |
|
14 |
def main():
|
15 |
+
print(f"Loading pipeline")
|
16 |
pipeline = load_pipeline()
|
17 |
|
18 |
+
print(f"Pipeline loaded")
|
19 |
+
|
20 |
with socket(AF_UNIX, SOCK_STREAM) as inference_socket:
|
21 |
inference_socket.bind(SOCKET)
|
22 |
|
23 |
chmod(SOCKET, 0o777)
|
24 |
|
25 |
inference_socket.listen(1)
|
26 |
+
|
27 |
+
print(f"Awaiting connections")
|
28 |
+
|
29 |
connection, _ = inference_socket.accept()
|
30 |
|
31 |
+
print(f"Connected")
|
32 |
+
|
33 |
with connection:
|
34 |
+
connection.setblocking(True)
|
35 |
+
|
36 |
while True:
|
37 |
size = int.from_bytes(connection.recv(2), byteorder)
|
38 |
|
39 |
+
print(f"Awaiting message of size {size}")
|
40 |
+
|
41 |
+
message = connection.recv(size).decode("utf-8")
|
42 |
+
|
43 |
+
if not message:
|
44 |
+
print(f"Empty message received")
|
45 |
+
continue
|
46 |
+
|
47 |
+
request = TextToImageRequest.model_validate_json(message)
|
48 |
|
49 |
image = infer(request, pipeline)
|
50 |
|