Skip to content

Commit bd0c946

Browse files
committed
refactor(follower): handle StopIteration in req callback separately
1 parent 57f6071 commit bd0c946

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ibmcloudant/features/changes_follower.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ def _request_callback(self):
181181
if self._stop.is_set():
182182
raise StopIteration
183183
self._buffer.put(results)
184+
except StopIteration as e:
185+
self.logger.debug('Iterator stopped.')
186+
self._buffer.join()
187+
self._buffer.put(e)
188+
break
184189
except Exception as e:
185190
self.logger.debug(f'Exception getting changes {e}')
186191
if (
@@ -196,10 +201,7 @@ def _request_callback(self):
196201
self._buffer.join()
197202
self._buffer.put(e)
198203
break
199-
if (
200-
type(e) is ApiException and e.status_code in [400, 401, 403, 404]
201-
or type(e) is StopIteration
202-
):
204+
if type(e) is ApiException and e.status_code in [400, 401, 403, 404]:
203205
self.logger.debug('Terminal error.')
204206
self._buffer.join()
205207
self._buffer.put(e)

0 commit comments

Comments
 (0)