Skip to content

Commit 6b82211

Browse files
bsmith89twiecki
authored andcommitted
Catch KeyboardInterrupt during sampling. (#1276)
Fix a regression introduced in df627ea. The intended behavior when a keyboard interrupt is to stop sampling and return the result.
1 parent da5627e commit 6b82211

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pymc3/sampling.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ def _sample(draws, step=None, start=None, trace=None, chain=0, tune=None,
156156
sampling = _iter_sample(draws, step, start, trace, chain,
157157
tune, model, random_seed)
158158
progress = progress_bar(draws)
159-
for i, strace in enumerate(sampling):
160-
try:
159+
try:
160+
for i, strace in enumerate(sampling):
161161
if progressbar:
162162
progress.update(i)
163-
except KeyboardInterrupt:
164-
strace.close()
163+
except KeyboardInterrupt:
164+
strace.close()
165165
return MultiTrace([strace])
166166

167167

0 commit comments

Comments
 (0)