|
28 | 28 | from .metadata import ServerStore, AppStore
|
29 | 29 | from .exception import RSConnectException
|
30 | 30 | from .bundle import _default_title, fake_module_file_from_directory
|
| 31 | +from .timeouts import get_timeout |
31 | 32 |
|
32 | 33 |
|
33 | 34 | class AbstractRemoteServer:
|
@@ -127,15 +128,14 @@ def __init__(self, url: str):
|
127 | 128 |
|
128 | 129 |
|
129 | 130 | class RSConnectClient(HTTPServer):
|
130 |
| - def __init__(self, server: RSConnectServer, cookies=None, timeout=30): |
| 131 | + def __init__(self, server: RSConnectServer, cookies=None): |
131 | 132 | if cookies is None:
|
132 | 133 | cookies = server.cookie_jar
|
133 | 134 | super().__init__(
|
134 | 135 | append_to_path(server.url, "__api__"),
|
135 | 136 | server.insecure,
|
136 | 137 | server.ca_data,
|
137 | 138 | cookies,
|
138 |
| - timeout, |
139 | 139 | )
|
140 | 140 | self._server = server
|
141 | 141 |
|
@@ -282,7 +282,7 @@ def get_content(self, content_guid):
|
282 | 282 | return results
|
283 | 283 |
|
284 | 284 | def wait_for_task(
|
285 |
| - self, task_id, log_callback, abort_func=lambda: False, timeout=None, poll_wait=0.5, raise_on_error=True |
| 285 | + self, task_id, log_callback, abort_func=lambda: False, timeout=get_timeout(), poll_wait=0.5, raise_on_error=True |
286 | 286 | ):
|
287 | 287 |
|
288 | 288 | last_status = None
|
@@ -387,7 +387,7 @@ def __init__(
|
387 | 387 | token=token,
|
388 | 388 | secret=secret,
|
389 | 389 | )
|
390 |
| - self.setup_client(cookies, timeout) |
| 390 | + self.setup_client(cookies) |
391 | 391 |
|
392 | 392 | @classmethod
|
393 | 393 | def fromConnectServer(cls, connect_server, **kwargs):
|
@@ -485,11 +485,11 @@ def setup_remote_server(
|
485 | 485 | else:
|
486 | 486 | raise RSConnectException("Unable to infer Connect server type and setup server.")
|
487 | 487 |
|
488 |
| - def setup_client(self, cookies=None, timeout=30, **kwargs): |
| 488 | + def setup_client(self, cookies=None, **kwargs): |
489 | 489 | if isinstance(self.remote_server, RSConnectServer):
|
490 |
| - self.client = RSConnectClient(self.remote_server, cookies, timeout) |
| 490 | + self.client = RSConnectClient(self.remote_server, cookies) |
491 | 491 | elif isinstance(self.remote_server, PositServer):
|
492 |
| - self.client = PositClient(self.remote_server, timeout) |
| 492 | + self.client = PositClient(self.remote_server) |
493 | 493 | else:
|
494 | 494 | raise RSConnectException("Unable to infer Connect client.")
|
495 | 495 |
|
@@ -678,7 +678,7 @@ def check_server_capabilities(self, capability_functions):
|
678 | 678 | def upload_rstudio_bundle(self, prepare_deploy_result, bundle_size: int, contents):
|
679 | 679 | upload_url = prepare_deploy_result.presigned_url
|
680 | 680 | parsed_upload_url = urlparse(upload_url)
|
681 |
| - with S3Client("{}://{}".format(parsed_upload_url.scheme, parsed_upload_url.netloc), timeout=120) as s3_client: |
| 681 | + with S3Client("{}://{}".format(parsed_upload_url.scheme, parsed_upload_url.netloc)) as s3_client: |
682 | 682 | upload_result = s3_client.upload(
|
683 | 683 | "{}?{}".format(parsed_upload_url.path, parsed_upload_url.query),
|
684 | 684 | prepare_deploy_result.presigned_checksum,
|
@@ -1028,14 +1028,14 @@ class PositClient(HTTPServer):
|
1028 | 1028 |
|
1029 | 1029 | _TERMINAL_STATUSES = {"success", "failed", "error"}
|
1030 | 1030 |
|
1031 |
| - def __init__(self, rstudio_server: PositServer, timeout: int = 30): |
| 1031 | + def __init__(self, rstudio_server: PositServer): |
1032 | 1032 | self._token = rstudio_server.token
|
1033 | 1033 | try:
|
1034 | 1034 | self._key = base64.b64decode(rstudio_server.secret)
|
1035 | 1035 | except binascii.Error as e:
|
1036 | 1036 | raise RSConnectException("Invalid secret.") from e
|
1037 | 1037 | self._server = rstudio_server
|
1038 |
| - super().__init__(rstudio_server.url, timeout=timeout) |
| 1038 | + super().__init__(rstudio_server.url) |
1039 | 1039 |
|
1040 | 1040 | def _get_canonical_request(self, method, path, timestamp, content_hash):
|
1041 | 1041 | return "\n".join([method, path, timestamp, content_hash])
|
@@ -1121,7 +1121,7 @@ def get_task(self, task_id):
|
1121 | 1121 | def get_current_user(self):
|
1122 | 1122 | return self.get("/v1/users/me")
|
1123 | 1123 |
|
1124 |
| - def wait_until_task_is_successful(self, task_id, timeout=180): |
| 1124 | + def wait_until_task_is_successful(self, task_id, timeout=get_timeout()): |
1125 | 1125 | print()
|
1126 | 1126 | print("Waiting for task: {}".format(task_id))
|
1127 | 1127 | start_time = time.time()
|
@@ -1372,7 +1372,7 @@ def emit_task_log(
|
1372 | 1372 | task_id,
|
1373 | 1373 | log_callback,
|
1374 | 1374 | abort_func=lambda: False,
|
1375 |
| - timeout=None, |
| 1375 | + timeout=get_timeout(), |
1376 | 1376 | poll_wait=0.5,
|
1377 | 1377 | raise_on_error=True,
|
1378 | 1378 | ):
|
|
0 commit comments