Skip to content

external-request-timeout (ODE8106)

Preview (since 0.16.2.5) · Related issues · View source

Derived from the odoo linter.

Fix is sometimes available.

This rule is unstable and in preview. The --preview flag is required for use.

What it does

Checks for calls to external request methods (requests.get, urllib.request.urlopen, smtplib.SMTP, ...) without an explicit timeout keyword argument.

Why is this bad?

Without a timeout these calls can block forever on an unresponsive peer, hanging the Odoo worker that runs them.

Example

response = requests.get(url)

Use instead:

response = requests.get(url, timeout=10)

Overlap with S113

S113 (request-without-timeout) detects the requests.*/httpx.* subset of this rule. This rule additionally covers ftplib, http.client, smtplib, serial, suds, urllib.request.urlopen and Odoo's IAP jsonrpc, matching pylint-odoo's external-request-timeout default list — enable one of the two, not both, to avoid duplicated reports on requests calls.

Fix safety

The fix inserts timeout=120 — the number of seconds is set by external-request-timeout-seconds. It is marked as unsafe because a call that used to block indefinitely now raises a timeout error once the limit passes. No fix is offered when the call unpacks **kwargs, which may already carry a timeout.

Options

The methods are written as dotted paths, e.g. requests.get.