mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-07-08 16:12:15 +02:00
fixed Ctrl-C behaviour on Windows
This commit is contained in:
parent
45f76cc532
commit
a749d31f8b
1 changed files with 18 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||||
import warnings
|
import warnings
|
||||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||||
|
import os
|
||||||
|
|
||||||
import core
|
import core
|
||||||
import models
|
import models
|
||||||
|
|
@ -19,3 +20,20 @@ from core import priors
|
||||||
@nottest
|
@nottest
|
||||||
def tests():
|
def tests():
|
||||||
Tester(testing).test(verbose=10)
|
Tester(testing).test(verbose=10)
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
"""
|
||||||
|
Fortran seems to like to intercept keyboard interrupts on windows.
|
||||||
|
This means that when a model is optimizing and the user presses Ctrl-C,
|
||||||
|
the program will crash. Since it's kind of nice to be able to stop
|
||||||
|
the optimization at any time, we define our own handler below.
|
||||||
|
|
||||||
|
"""
|
||||||
|
import win32api
|
||||||
|
import thread
|
||||||
|
|
||||||
|
def handler(sig, hook=thread.interrupt_main):
|
||||||
|
hook()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
win32api.SetConsoleCtrlHandler(handler, 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue