Blob Blame Raw
diff --git a/kernprof.py b/kernprof.py
index 108d36e..6461cf6 100755
--- a/kernprof.py
+++ b/kernprof.py
@@ -102,6 +102,8 @@ class ContextualProfile(Profile):
                 self.enable_by_count()
                 try:
                     item = g.send(input)
+                except StopIteration:
+                    return
                 finally:
                     self.disable_by_count()
                 input = (yield item)
diff --git a/line_profiler.py b/line_profiler.py
index a481dd2..5744d05 100755
--- a/line_profiler.py
+++ b/line_profiler.py
@@ -100,6 +100,8 @@ class LineProfiler(CLineProfiler):
                 self.enable_by_count()
                 try:
                     item = g.send(input)
+                except StopIteration:
+                    return
                 finally:
                     self.disable_by_count()
                 input = (yield item)