Skip to content

Commit 825ec09

Browse files
committed
Do not set signal when not in main thread
Resource.__enter__ calls signal which cannot be called when in a different thread from main.
1 parent 8089522 commit 825ec09

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ocp_resources/resource.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import re
88
import sys
9+
import threading
910
from collections.abc import Callable, Generator
1011
from io import StringIO
1112
from signal import SIGINT, signal
@@ -582,7 +583,8 @@ def to_dict(self) -> None:
582583
self._base_body()
583584

584585
def __enter__(self) -> Any:
585-
signal(SIGINT, self._sigint_handler)
586+
if threading.current_thread().native_id == threading.main_thread().native_id:
587+
signal(SIGINT, self._sigint_handler)
586588
return self.deploy(wait=self.wait_for_resource)
587589

588590
def __exit__(

0 commit comments

Comments
 (0)