Skip to content

Commit 21587e3

Browse files
authored
Lower signal exception to warning when running on non-main thread (#96)
* Reduce exception of signal to warning and logging the error
1 parent 89b7f21 commit 21587e3

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/PythonClient/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import fileinput
77

8-
package_version = "0.5.2.dev7"
8+
package_version = "0.5.2.dev8"
99

1010
with open("README.md", "r") as fh:
1111
long_description = fh.read()

src/PythonClient/src/quixstreams/app.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ctypes
2+
import logging
23
import traceback
34
import signal
45
from typing import Callable
@@ -98,7 +99,16 @@ def wrapper():
9899
# the interop, there is no need to throw an exception that is impossible to handle anyway
99100
def keyboard_interrupt_handler(signal, frame):
100101
pass
101-
signal.signal(signal.SIGINT, keyboard_interrupt_handler)
102+
try:
103+
signal.signal(signal.SIGINT, keyboard_interrupt_handler)
104+
except ValueError as ex:
105+
# If this exception happens, it means the signal handling is running on non-main thread.
106+
# The end result is that keyboard or shutdown interruption will not work here or in C# interop.
107+
# While that is not optimal, it is still better to let the application at least function
108+
# and log the exception + warning than completely block it from functioning.
109+
traceback.print_exc()
110+
logging.log(logging.WARNING, "Shutdown may not work as expected. See error.")
111+
102112

103113
try:
104114
if cancellation_token is not None:

src/builds/csharp/nuget/build_nugets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from typing import List
88

99
version = "0.5.2.0"
10-
informal_version = "0.5.2.0-dev7"
11-
nuget_version = "0.5.2.0-dev7"
10+
informal_version = "0.5.2.0-dev8"
11+
nuget_version = "0.5.2.0-dev8"
1212

1313

1414
def updatecsproj(projfilepath):

0 commit comments

Comments
 (0)