Skip to content

Commit 0eed8e0

Browse files
committed
Remove signal handling in examples
Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
1 parent e16c211 commit 0eed8e0

20 files changed

Lines changed: 0 additions & 177 deletions

packages/pynumaflow-lite/manifests/accumulator/accumulator_stream_sorter.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,5 @@ async def main():
130130
pass
131131
return
132132

133-
134-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
135-
136-
signal.signal(signal.SIGINT, signal.default_int_handler)
137-
try:
138-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
139-
except AttributeError:
140-
pass
141-
142133
if __name__ == "__main__":
143134
asyncio.run(main())

packages/pynumaflow-lite/manifests/batchmap/batchmap_cat.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ async def handler(
2222
responses.append(resp)
2323
return responses
2424

25-
26-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
27-
signal.signal(signal.SIGINT, signal.default_int_handler)
28-
try:
29-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
30-
except AttributeError:
31-
pass
32-
33-
3425
async def start(
3526
f: Callable[
3627
[AsyncIterable[batchmapper.Datum]], Awaitable[batchmapper.BatchResponses]

packages/pynumaflow-lite/manifests/map/map_cat.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ async def handler(self, keys: list[str], payload: mapper.Datum) -> mapper.Messag
1717

1818
return messages
1919

20-
21-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
22-
signal.signal(signal.SIGINT, signal.default_int_handler)
23-
try:
24-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
25-
except AttributeError:
26-
pass
27-
28-
2920
async def start(f: Callable[[list[str], mapper.Datum], Awaitable[mapper.Messages]]):
3021
server = mapper.MapAsyncServer()
3122

packages/pynumaflow-lite/manifests/mapstream/mapstream_cat.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ async def handler(
1818
for s in parts:
1919
yield Message(s.encode(), keys)
2020

21-
22-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
23-
signal.signal(signal.SIGINT, signal.default_int_handler)
24-
try:
25-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
26-
except AttributeError:
27-
pass
28-
29-
3021
async def start(f: Callable[[list[str], mapstreamer.Datum], AsyncIterator[Message]]):
3122
# Use default socket/info file locations; no explicit sock file passed
3223
server = mapstreamer.MapStreamAsyncServer()

packages/pynumaflow-lite/manifests/reduce/reduce_counter_class.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ async def handler(
2626
out.append(reducer.Message(msg, keys))
2727
return out
2828

29-
30-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
31-
signal.signal(signal.SIGINT, signal.default_int_handler)
32-
try:
33-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
34-
except AttributeError:
35-
pass
36-
37-
3829
async def start(creator: type[reducer.Reducer], init_args: tuple):
3930
sock_file = "/var/run/numaflow/reduce.sock"
4031
server_info_file = "/var/run/numaflow/reducer-server-info"

packages/pynumaflow-lite/manifests/reducestream/reducestream_counter.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ async def handler(
7070
print(f"Yielding final result: counter={self.counter}")
7171
yield reducestreamer.Message(msg, keys=keys)
7272

73-
74-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
75-
signal.signal(signal.SIGINT, signal.default_int_handler)
76-
try:
77-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
78-
except AttributeError:
79-
pass
80-
81-
8273
async def start(creator: type, init_args: tuple):
8374
"""Start the reduce stream server."""
8475
sock_file = "/var/run/numaflow/reducestream.sock"

packages/pynumaflow-lite/manifests/session_reduce/session_reduce_counter_class.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,5 @@ async def main():
7878
pass
7979
return
8080

81-
82-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
83-
signal.signal(signal.SIGINT, signal.default_int_handler)
84-
try:
85-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
86-
except AttributeError:
87-
pass
88-
8981
if __name__ == "__main__":
9082
asyncio.run(main())

packages/pynumaflow-lite/manifests/sideinput/sideinput_example.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,6 @@ def update_data_from_file(self, path):
8585
except Exception as e:
8686
print(f"Error reading file: {e}")
8787

88-
89-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
90-
signal.signal(signal.SIGINT, signal.default_int_handler)
91-
try:
92-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
93-
except AttributeError:
94-
pass
95-
96-
9788
async def start_sideinput():
9889
"""Start the SideInput retriever server."""
9990
server = sideinputer.SideInputAsyncServer()

packages/pynumaflow-lite/manifests/sink/sink_log.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ async def handler(self, datums: AsyncIterable[sinker.Datum]) -> sinker.Responses
2626
# we can use Response.as_fallback(msg.id) to write the message to fallback sink
2727
return responses
2828

29-
30-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
31-
signal.signal(signal.SIGINT, signal.default_int_handler)
32-
try:
33-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
34-
except AttributeError:
35-
pass
36-
37-
3829
async def start(
3930
f: Callable[[AsyncIterator[sinker.Datum]], Awaitable[sinker.Responses]],
4031
):

packages/pynumaflow-lite/manifests/source/simple_source.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ async def partitions_handler(self) -> sourcer.PartitionsResponse:
9292
"""
9393
return sourcer.PartitionsResponse(partitions=[self.partition_idx])
9494

95-
96-
# Optional: ensure default signal handlers are in place so asyncio.run can handle them cleanly.
97-
signal.signal(signal.SIGINT, signal.default_int_handler)
98-
try:
99-
signal.signal(signal.SIGTERM, signal.SIG_DFL)
100-
except AttributeError:
101-
pass
102-
103-
10495
async def start():
10596
server = sourcer.SourceAsyncServer()
10697

0 commit comments

Comments
 (0)