Skip to content

Commit 70d983b

Browse files
committed
Ignore transport errors when closing down worker threads in the examples.
1 parent 89daab1 commit 70d983b

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

src/example_animated.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,5 @@ def animate(fps):
168168
for t in threading.enumerate():
169169
try:
170170
t.join()
171-
except RuntimeError:
171+
except (TransportError, RuntimeError):
172172
pass

src/example_basic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from PIL import Image, ImageDraw, ImageFont
1717
from StreamDeck.DeviceManager import DeviceManager
1818
from StreamDeck.ImageHelpers import PILHelper
19+
from StreamDeck.Transport.Transport import TransportError
1920

2021
# Folder location of image assets used by this example.
2122
ASSETS_PATH = os.path.join(os.path.dirname(__file__), "Assets")
@@ -140,5 +141,5 @@ def key_change_callback(deck, key, state):
140141
for t in threading.enumerate():
141142
try:
142143
t.join()
143-
except RuntimeError:
144+
except (TransportError, RuntimeError):
144145
pass

src/example_neo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from PIL import Image, ImageDraw, ImageFont
1818
from StreamDeck.DeviceManager import DeviceManager
1919
from StreamDeck.ImageHelpers import PILHelper
20+
from StreamDeck.Transport.Transport import TransportError
2021

2122
# Folder location of image assets used by this example.
2223
ASSETS_PATH = os.path.join(os.path.dirname(__file__), "Assets")
@@ -166,5 +167,5 @@ def set_random_touch_color(deck, key):
166167
for t in threading.enumerate():
167168
try:
168169
t.join()
169-
except RuntimeError:
170+
except (TransportError, RuntimeError):
170171
pass

src/example_pedal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import threading
1515

1616
from StreamDeck.DeviceManager import DeviceManager
17+
from StreamDeck.Transport.Transport import TransportError
1718

1819

1920
def key_change_callback(deck, key, state):
@@ -40,5 +41,5 @@ def key_change_callback(deck, key, state):
4041
for t in threading.enumerate():
4142
try:
4243
t.join()
43-
except RuntimeError:
44+
except (TransportError, RuntimeError):
4445
pass

src/example_plus.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from PIL import Image
1515
from StreamDeck.DeviceManager import DeviceManager
1616
from StreamDeck.Devices.StreamDeck import DialEventType, TouchscreenEventType
17+
from StreamDeck.Transport.Transport import TransportError
1718

1819
# Folder location of image assets used by this example.
1920
ASSETS_PATH = os.path.join(os.path.dirname(__file__), "Assets")
@@ -131,5 +132,5 @@ def touchscreen_event_callback(deck, evt_type, value):
131132
for t in threading.enumerate():
132133
try:
133134
t.join()
134-
except RuntimeError:
135+
except (TransportError, RuntimeError):
135136
pass

src/example_tileimage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from PIL import Image, ImageOps
1818
from StreamDeck.DeviceManager import DeviceManager
1919
from StreamDeck.ImageHelpers import PILHelper
20+
from StreamDeck.Transport.Transport import TransportError
2021

2122
# Folder location of image assets used by this example.
2223
ASSETS_PATH = os.path.join(os.path.dirname(__file__), "Assets")
@@ -144,5 +145,5 @@ def key_change_callback(deck, key, state):
144145
for t in threading.enumerate():
145146
try:
146147
t.join()
147-
except RuntimeError:
148+
except (TransportError, RuntimeError):
148149
pass

0 commit comments

Comments
 (0)