1010from robot .api .deco import not_keyword
1111from robot .api import logger
1212from robot .libraries .BuiltIn import BuiltIn
13+ from robot .errors import ExecutionFailed
1314from pyppeteer .browser import Browser
1415from PuppeteerLibrary .library_context .ilibrary_context import iLibraryContext
1516from PuppeteerLibrary .library_context .library_context_factory import LibraryContextFactory
@@ -120,7 +121,7 @@ def __init__(self, disable_python_logging=True):
120121 try :
121122 signal .signal (signal .SIGINT , self .terminal_signal_handler )
122123 except :
123- print ('Warning: Not handle ternial signal' )
124+ print ('Warning: Not handle terminal signal' )
124125
125126 try :
126127 self .loop = asyncio .get_event_loop ()
@@ -215,7 +216,7 @@ def failure_occurred(self):
215216 def terminal_signal_handler (self , sig , frame ):
216217 print ('You pressed Ctrl+C!' )
217218 BuiltIn ().run_keyword_and_ignore_error ('Close Puppeteer' )
218- sys . exit ( 0 )
219+ self . _stop_execution_gracefully ( )
219220
220221 def _disable_python_logging (self ):
221222 # Force node not throw any unhandled task
@@ -226,6 +227,9 @@ def _disable_python_logging(self):
226227 logging .disable (logging .CRITICAL )
227228 logging .warning ('Protocol problem:' )
228229
230+ def _stop_execution_gracefully (self ):
231+ raise ExecutionFailed ('Execution terminated by signal' , exit = True )
232+
229233from ._version import get_versions
230234__version__ = get_versions ()['version' ]
231235del get_versions
0 commit comments