Skip to content

Commit 569231e

Browse files
committed
FIX: Fix blocking on iteration __del__
1 parent 3d1ab19 commit 569231e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
- Added export of `TradingEvent` enum from `databento_dbn` to the root `databento` package
99
- Removed upper bound for supported `python` versions; the constraint is now `^3.9`
1010

11+
#### Bug fixes
12+
- Fixed an issue where sending a `KeyboardInterrupt` during iteration of the `Live` client could block execution waiting for the connection to close
13+
1114
## 0.47.0 - 2024-12-17
1215

1316
#### Enhancements

databento/live/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def __init__(
116116

117117
def __del__(self) -> None:
118118
try:
119-
self.stop()
119+
self.terminate()
120120
except (AttributeError, ValueError):
121121
pass
122122

@@ -644,10 +644,11 @@ def __iter__(self) -> LiveIterator:
644644
return self
645645

646646
def __del__(self) -> None:
647-
if self.client.is_connected():
648-
self.client.stop()
649-
self.client.block_for_close()
647+
try:
648+
self.client.terminate()
650649
logger.debug("iteration aborted")
650+
except ValueError:
651+
pass
651652

652653
async def __anext__(self) -> DBNRecord:
653654
if not self._dbn_queue.is_enabled():

0 commit comments

Comments
 (0)