fix: add request timeouts to prevent indefinite hangs (#239)#240
Merged
Conversation
…P connections Set a default (10s connect, 2min read) timeout on every requests.Session via functools.partial so all API calls are covered without per-call-site changes. job.run() overrides this with (30s connect, 30min read) since job execution can legitimately take up to 30 minutes. Applied to both NovemAPI and NovemGQL which manages its own session independently. Closes novem-code#239
myme
approved these changes
Jun 17, 2026
bjornars
added a commit
that referenced
this pull request
Jun 18, 2026
Add a README "Error handling" section covering the two newest changes: - PR #236: writes now raise NovemException (or a subclass) carrying the server message instead of silently printing a placeholder. Documents the exception hierarchy (all importable from novem.exceptions) and the create PUT 409 no-op for objects that already exist. - PR #240: requests now time out instead of hanging, with the default (10s, 2min) and job.run() (30s, 30min) values and the resulting requests.exceptions.Timeout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
(10s connect, 2min read)timeout on everyrequests.Sessionviafunctools.partialonsession.request— one line inNovemAPI.__init__covers all subclasses with no per-call-site changesjob.run()overrides to(30s connect, 30min read)since job execution can legitimately take up to 30 minutesNovemGQLwhich manages its own session independently and was not covered by theNovemAPIchangeHow it works
functools.partialkeyword arguments are overridable at call time, sojob.run()can passtimeout=(30, 1800)and it takes precedence over the default.Test plan
test_session_default_timeout— mockssession.sendand verifies the default(10, 120)timeout flows through the full chain (functools.partial→session.request→session.send) for an ordinary API calltest_job_run_no_files_uses_job_timeout— same approach, verifies(30, 1800)for the empty-JSON branch ofrun()test_job_run_with_files_uses_job_timeout— same for the multipart-upload branch ofrun()Closes #239