mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-11 18:39:30 +00:00
feature(servers): set default timeout of server operations to 10 min
This commit is contained in:
parent
b001e198bf
commit
c53f35c947
|
@ -12,6 +12,8 @@ from selfprivacy_api.services.generic_size_counter import get_storage_usage
|
|||
from selfprivacy_api.services.owned_path import OwnedPath
|
||||
from selfprivacy_api.utils.waitloop import wait_until_true
|
||||
|
||||
DEFAULT_START_STOP_TIMEOUT = 10 * 60
|
||||
|
||||
|
||||
class ServiceStatus(Enum):
|
||||
"""Enum for service status"""
|
||||
|
@ -260,6 +262,7 @@ class StoppedService:
|
|||
assert service.get_status() == ServiceStatus.INACTIVE
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(self, service: Service):
|
||||
self.service = service
|
||||
self.original_status = service.get_status()
|
||||
|
@ -268,10 +271,16 @@ class StoppedService:
|
|||
self.original_status = self.service.get_status()
|
||||
if self.original_status != ServiceStatus.INACTIVE:
|
||||
self.service.stop()
|
||||
wait_until_true(lambda: self.service.get_status() == ServiceStatus.INACTIVE)
|
||||
wait_until_true(
|
||||
lambda: self.service.get_status() == ServiceStatus.INACTIVE,
|
||||
timeout_sec=DEFAULT_START_STOP_TIMEOUT,
|
||||
)
|
||||
return self.service
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
if self.original_status in [ServiceStatus.ACTIVATING, ServiceStatus.ACTIVE]:
|
||||
self.service.start()
|
||||
wait_until_true(lambda: self.service.get_status() == ServiceStatus.ACTIVE)
|
||||
wait_until_true(
|
||||
lambda: self.service.get_status() == ServiceStatus.ACTIVE,
|
||||
timeout_sec=DEFAULT_START_STOP_TIMEOUT,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue