Skip to content

Commit

Permalink
Merge pull request #2228 from Raalsky/bug/registry-timeout
Browse files Browse the repository at this point in the history
(#2195) Added timeout to registry download call
  • Loading branch information
beckjake authored Mar 24, 2020
2 parents 8487166 + 1c60882 commit 367bf68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

### Fixes
- When a jinja value is undefined, give a helpful error instead of failing with cryptic "cannot pickle ParserMacroCapture" errors ([#2110](https://github.com/fishtown-analytics/dbt/issues/2110), [#2184](https://github.com/fishtown-analytics/dbt/pull/2184))
- Added timeout to registry download call ([#2195](https://github.com/fishtown-analytics/dbt/issues/2195), [#2228](https://github.com/fishtown-analytics/dbt/pull/2228))

Contributors:
- [@raalsky](https://github.com/Raalsky) ([#2224](https://github.com/fishtown-analytics/dbt/pull/2224), [#2228](https://github.com/fishtown-analytics/dbt/pull/2228))

Contributors:
- [@raalsky](https://github.com/Raalsky) ([#2224](https://github.com/fishtown-analytics/dbt/pull/2224))
Expand Down
7 changes: 4 additions & 3 deletions core/dbt/clients/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests
import stat
from typing import (
Type, NoReturn, List, Optional, Dict, Any, Tuple, Callable
Type, NoReturn, List, Optional, Dict, Any, Tuple, Callable, Union
)

import dbt.exceptions
Expand Down Expand Up @@ -323,8 +323,9 @@ def run_cmd(
return out, err


def download(url: str, path: str) -> None:
response = requests.get(url)
def download(url: str, path: str, timeout: Union[float, tuple] = None) -> None:
connection_timeout = timeout or float(os.getenv('DBT_HTTP_TIMEOUT', 10))
response = requests.get(url, timeout=connection_timeout)
with open(path, 'wb') as handle:
for block in response.iter_content(1024 * 64):
handle.write(block)
Expand Down

0 comments on commit 367bf68

Please sign in to comment.