github3.py icon indicating copy to clipboard operation
github3.py copied to clipboard

Can we expose the `timeout` parameter to `Repository.create_tree()` to create large tree objects?

Open rduve opened this issue 1 year ago • 0 comments

Currently, when trying to create a tree with large data there is a timeout error:

import github3

gh = github3.login(token=<token>)
repo = gh.repository(<org>, <repo>)
...
# Make big tree_data and tree_sha here.
...
tree = repo.create_tree(tree_data, tree_sha)

github3.exceptions.ConnectionError: <class 'requests.exceptions.ReadTimeout'>: A connection-level exception occurred: HTTPSConnectionPool(host='api.github.com', port=443): Read timed out. (read timeout=10)

Specifically, that tree_data object has 1610 blobs and is about 300 KB serialized.

Manually adding a timeout=60 to the self._post() in that function: https://github.com/sigmavirus24/github3.py/blob/62367c9fd7d3e2232c3a2d3c7751759fc8e404b8/src/github3/repos/repo.py#L1392

allows the tree to successfully be created.

My goal is to not get the timeout when executing create_tree. Would it be a helpful addition to github3 if that timeout could be specified without patching the _post function? If not, would a PR that adds timeout to the create_tree function contract be welcome?

rduve avatar Jul 25 '24 19:07 rduve