Hi team,
We're encountering a critical issue when using ld.discovery.Chain
to fetch futures option chain constituents. When making multiple sequential calls to ld.discovery.Chain(universe).constituents
, if one call fails with an LDError
, subsequent calls cause the Python instance or thread to freeze.
Issue Description:
- Multiple calls to
ld.discovery.Chain(universe).constituents
work fine individually - However, if one call fails and throws an
LDError
, the next call in the sequence freezes - The freeze occurs specifically at line 95 in
lseg.data.delivery._stream._stream
Code Example:
if __name__ == '__main__':
import lseg.data as ld
ld.open_session()
def _fetch_option_chain(universes: list[str]) -> None:
for univers in universes:
print(f"starts fetch option chain for univers '{univers}'")
try:
ld.discovery.Chain(univers).constituents
except ld.errors.LDError:
print(f"error occurred for univers '{univers}'")
print(f"finished fetch option chain for univers '{univers}'")
_fetch_option_chain(["0#CLQ25+", "0#CLU25+"]) # freezing when fetching 0#CLU25+ after 0#CLQ25+ failed (one thread occupied)
_fetch_option_chain(["0#CLU25+"]) # works
ld.close_session()
Current Workaround: We've temporarily resolved this by closing and reopening the session after each LDError
, but this doesn't address the underlying threading issue and impacts performance.
Environment:
- Python version: 3.13
- lseg.data version: 2.1.1
Could you please investigate this threading/connection state issue? It appears that failed requests are not properly cleaning up their resources, causing subsequent requests to hang.
Thanks for your assistance.