Skip to content

Commit 678de3e

Browse files
Jupyter interrupt fix (wandb#1257)
* fix * flag->else:
1 parent 1519c74 commit 678de3e

2 files changed

Lines changed: 30 additions & 8 deletions

File tree

wandb/sdk/wandb_run.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131
from wandb.data_types import _datatypes_set_callback
3232
from wandb.errors import Error
3333
from wandb.interface.summary_record import SummaryRecord
34-
from wandb.lib import config_util, filenames, module, proto_util, redirect, sparkline
34+
from wandb.lib import (
35+
config_util,
36+
filenames,
37+
ipython,
38+
module,
39+
proto_util,
40+
redirect,
41+
sparkline,
42+
)
3543
from wandb.util import add_import_hook, sentry_set_scope, to_forward_slash_path
3644
from wandb.viz import Visualize
3745

@@ -1128,15 +1136,18 @@ def _atexit_cleanup(self, exit_code=None):
11281136
self._on_finish()
11291137
except KeyboardInterrupt:
11301138
wandb.termerror("Control-C detected -- Run data was not synced")
1131-
os._exit(-1)
1139+
if ipython._get_python_type() == "python":
1140+
os._exit(-1)
11321141
except Exception as e:
11331142
self._console_stop()
11341143
self._backend.cleanup()
11351144
logger.error("Problem finishing run", exc_info=e)
11361145
wandb.termerror("Problem finishing run")
11371146
traceback.print_exception(*sys.exc_info())
1138-
os._exit(-1)
1139-
self._on_final()
1147+
if ipython._get_python_type() == "python":
1148+
os._exit(-1)
1149+
else:
1150+
self._on_final()
11401151

11411152
def _console_start(self):
11421153
logger.info("atexit reg")

wandb/sdk_py27/wandb_run.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131
from wandb.data_types import _datatypes_set_callback
3232
from wandb.errors import Error
3333
from wandb.interface.summary_record import SummaryRecord
34-
from wandb.lib import config_util, filenames, module, proto_util, redirect, sparkline
34+
from wandb.lib import (
35+
config_util,
36+
filenames,
37+
ipython,
38+
module,
39+
proto_util,
40+
redirect,
41+
sparkline,
42+
)
3543
from wandb.util import add_import_hook, sentry_set_scope, to_forward_slash_path
3644
from wandb.viz import Visualize
3745

@@ -1128,15 +1136,18 @@ def _atexit_cleanup(self, exit_code=None):
11281136
self._on_finish()
11291137
except KeyboardInterrupt:
11301138
wandb.termerror("Control-C detected -- Run data was not synced")
1131-
os._exit(-1)
1139+
if ipython._get_python_type() == "python":
1140+
os._exit(-1)
11321141
except Exception as e:
11331142
self._console_stop()
11341143
self._backend.cleanup()
11351144
logger.error("Problem finishing run", exc_info=e)
11361145
wandb.termerror("Problem finishing run")
11371146
traceback.print_exception(*sys.exc_info())
1138-
os._exit(-1)
1139-
self._on_final()
1147+
if ipython._get_python_type() == "python":
1148+
os._exit(-1)
1149+
else:
1150+
self._on_final()
11401151

11411152
def _console_start(self):
11421153
logger.info("atexit reg")

0 commit comments

Comments
 (0)