-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from gregoil/feature/add-breakpoint-signal
Added breakpoint signal
- Loading branch information
Showing
4 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Signals usage in Rotest.""" | ||
# pylint: disable=global-statement,no-member | ||
import sys | ||
import signal | ||
|
||
|
||
BREAKPOINT_SIGNAL_REGISTERED = False | ||
|
||
|
||
class BreakPointException(Exception): | ||
"""An exception to raise on the break signal.""" | ||
|
||
|
||
def raise_exception_handler(_signum, _frame): | ||
"""Raise a break-point exception.""" | ||
raise BreakPointException() | ||
|
||
|
||
def register_break_signal(): | ||
"""Register raising an exception on break signal if needed.""" | ||
global BREAKPOINT_SIGNAL_REGISTERED | ||
if BREAKPOINT_SIGNAL_REGISTERED: | ||
return | ||
|
||
BREAKPOINT_SIGNAL_REGISTERED = True | ||
|
||
if sys.platform == "win32": | ||
signal.signal(signal.SIGBREAK, raise_exception_handler) | ||
|
||
else: | ||
signal.signal(signal.SIGQUIT, raise_exception_handler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters