Skip to content

Commit 0f81cfb

Browse files
committed
server: client: fix image preview on non-windows os
1 parent 8b74c8e commit 0f81cfb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

examples/server/test_client.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import requests, json, base64
22
from io import BytesIO
33
from PIL import Image, PngImagePlugin, ImageShow
4-
from threading import Thread
4+
import os
5+
if os.name == 'nt':
6+
from threading import Thread
7+
58

69
from typing import List
710

@@ -128,9 +131,12 @@ def showImages(imgs: List[Image.Image]) -> None:
128131
None
129132
"""
130133
for (i,img) in enumerate(imgs):
131-
t = Thread(target=show_img, args=(img, f"IMG {i}"))
132-
t.setDaemon(True)
133-
t.start
134+
if os.name == 'nt':
135+
t = Thread(target=show_img, args=(img, f"IMG {i}"))
136+
t.setDaemon(True)
137+
t.start
138+
else:
139+
show_img(img, f"IMG {i}")
134140

135141
def saveImages(imgs: List[Image.Image], path: str) -> None:
136142
"""

0 commit comments

Comments
 (0)