Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added timeout from env variable to IB client requests #2012

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# -------------------------------------------------------------------------------------------------

import functools
import os
from collections.abc import Callable
from decimal import Decimal
from inspect import iscoroutinefunction
Expand Down Expand Up @@ -109,7 +110,7 @@ async def _subscribe(
"""
if not (subscription := self._subscriptions.get(name=name)):
self._log.info(
f"Creating and registering a new Subscription instance for {subscription}",
f"Creating and registering a new Subscription instance for {name}",
)
req_id = self._next_req_id()
if subscription_method == self.subscribe_historical_bars:
Expand Down Expand Up @@ -390,7 +391,8 @@ async def get_historical_bars(
return []
self._log.debug(f"reqHistoricalData: {request.req_id=}, {contract=}")
request.handle()
return await self._await_request(request, timeout, default_value=[])
ib_timeout = int(os.environ.get("IB_REQUEST_TIMEOUT", timeout))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @marcodambros

If you can remove these lines sourcing the timeout from an env var, we can then merge this and I'll add a config option for the timeout.

return await self._await_request(request, ib_timeout, default_value=[])
else:
self._log.info(f"Request already exist for {request}")
return []
Expand Down