Skip to content

Commit

Permalink
Callback must return a generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmax committed Jun 24, 2016
1 parent 21660fd commit c6ae03f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/inline_requests/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ def __init__(self, callback, **kwargs):

def __call__(self, response):
output = iterate_spider_output(self.callback(response=response, **self.kwargs))
if isinstance(output, types.GeneratorType):
return self._unwindGenerator(output)
else:
return output
if not isinstance(output, types.GeneratorType):
raise ValueError("Callback must return a generator type")
return self._unwindGenerator(output)

def _unwindGenerator(self, generator, _prev=None):
while True:
Expand Down

0 comments on commit c6ae03f

Please sign in to comment.