Skip to content

Commit f593181

Browse files
four4fishlexierule
authored andcommitted
fix TypeError cause failure in singal_connector teardown (#10961)
1 parent 50b89db commit f593181

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2222
- Fixed an issue with `DDPSpawnPlugin` and related plugins leaving a temporary checkpoint behind ([#10934](https://github.com/PyTorchLightning/pytorch-lightning/pull/10934))
2323

2424

25+
- Fixed TypeError cause failure in `singal_connector` `teardown` method by adding None check ([#10961](https://github.com/PyTorchLightning/pytorch-lightning/pull/10961))
26+
27+
2528
## [1.5.4] - 2021-11-30
2629

2730
### Fixed

pytorch_lightning/trainer/connectors/signal_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def _is_on_slurm(self) -> bool:
144144

145145
@staticmethod
146146
def _has_already_handler(signum: Signals) -> bool:
147-
return signal.getsignal(signum) is not signal.SIG_DFL
147+
return signal.getsignal(signum) not in (None, signal.SIG_DFL)
148148

149149
@staticmethod
150150
def _register_signal(signum: Signals, handlers: HandlersCompose) -> None:

tests/trainer/connectors/test_signal_connector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def signal_handler(self):
102102
@pytest.mark.parametrize(
103103
["handler", "expected_return"],
104104
[
105+
(None, False),
105106
(signal.Handlers.SIG_IGN, True),
106107
(signal.Handlers.SIG_DFL, False),
107108
(signal_handler, True),

0 commit comments

Comments
 (0)