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

fix: display timeout calling context #27

Merged
merged 5 commits into from
Jan 11, 2024
Merged
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
14 changes: 9 additions & 5 deletions eth_retry/eth_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def should_retry(e: Exception, failures: int) -> bool:

return False


_aio_files = [
"asyncio/events.py"
"asyncio/base_events.py"
]
def _get_caller_details_from_stack() -> str:
code_context = inspect.stack()[2].code_context
if code_context is None:
return f"{inspect.stack()[2].filename} line {inspect.stack()[2].lineno}"
return f"{inspect.stack()[2].filename} line {inspect.stack()[2].lineno} {[code_context[0].strip()]}"
for frame in inspect.stack()[2:]:
if all(filename not in frame.filename for filename in _aio_files):
details = f"{frame.filename} line {frame.lineno}"
context = frame.code_context
return details if context is None else f"{details} {[context[0].strip()]}"
Loading