Skip to content

Timeouts and retries are hard to control #165

@gvanrossum

Description

@gvanrossum

There is retry behavior inside Python-TypeChat's HttpxLanguageModel, but the factory functions used to create an HttpxLanguageModel instance don't have parameters to set these. Therefore, we appear to be stuck with three retries, each with the same timeout of 10 seconds, and a 1-second pause in between.

Fortunately, HttpxLanguageModel's class variables (where these parameters live) can be set on the class (changing the defaults -- though note that the class is not exported from the typechat package) or on the instance (changing that instance's parameters). We should use this to make the timeout and the retry limit settable from a command-line flag in query.py, and given a different default (I've found that a timeout of 20 seconds is much better: if a request doesn't succeed on the first try, it usually does on the second, even though the timeout is the same).

This can be done in convknowledge.py, which is the only place where create_language_model() is called.

This doesn't make the retry behavior exponential, though -- that would require either a code change to Python-TypeChat, or a wrapper that reimplements the retry logic and increases the instance's timeout on each try (but resetting it for each call to the wrapper).

Note that IIUC the retry_count default of 3 actually causes up to 4 tries to happen -- if it's set to zero, the "loop-and-a-half" logic tries once. This is slightly surprising.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions