Skip to content

Commit 8ac3073

Browse files
committed
fix: Avoid return from finally: block
This fixes a SyntaxWarning on Python 3.14. ``` ❯ uvx --no-cache --python 3.14.0 --with posthog==6.7.11 python -c "import posthog" Installed 11 packages in 5ms .../lib/python3.14/site-packages/posthog/consumer.py:92: SyntaxWarning: 'return' in a 'finally' block return success ````
1 parent 7dd6229 commit 8ac3073

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

posthog/consumer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ def upload(self):
8484
self.log.error("error uploading: %s", e)
8585
success = False
8686
if self.on_error:
87-
self.on_error(e, batch)
87+
try:
88+
self.on_error(e, batch)
89+
except Exception as e:
90+
self.log.error("on_error handler failed: %s", e)
8891
finally:
8992
# mark items as acknowledged from queue
9093
for item in batch:
9194
self.queue.task_done()
92-
return success
95+
96+
return success
9397

9498
def next(self):
9599
"""Return the next batch of items to upload."""

0 commit comments

Comments
 (0)