summary refs log tree commit diff
path: root/synapse/config/_base.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-04-23 14:12:47 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2021-04-23 14:12:47 +0100
commitd2b3c47ba31fec1df4d06f1c2aa7ed29e309498d (patch)
tree7a80e170fdec14dfd3e78cd4984ff39c89beb48a /synapse/config/_base.py
parentMerge commit 'd9f1dccba' into anoa/dinsic_release_1_31_0 (diff)
parentClean up the user directory sample config section (#9385) (diff)
downloadsynapse-d2b3c47ba31fec1df4d06f1c2aa7ed29e309498d.tar.xz
Merge commit 'e22b71810' into anoa/dinsic_release_1_31_0
Diffstat (limited to 'synapse/config/_base.py')
-rw-r--r--synapse/config/_base.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py

index 40af1979c4..57f454fc9f 100644 --- a/synapse/config/_base.py +++ b/synapse/config/_base.py
@@ -22,7 +22,7 @@ from collections import OrderedDict from hashlib import sha256 from io import open as io_open from textwrap import dedent -from typing import Any, Iterable, List, MutableMapping, Optional +from typing import Any, Iterable, List, MutableMapping, Optional, Union import attr import jinja2 @@ -148,7 +148,20 @@ class Config: return int(value) * size @staticmethod - def parse_duration(value): + def parse_duration(value: Union[str, int]) -> int: + """Convert a duration as a string or integer to a number of milliseconds. + + If an integer is provided it is treated as milliseconds and is unchanged. + + String durations can have a suffix of 's', 'm', 'h', 'd', 'w', or 'y'. + No suffix is treated as milliseconds. + + Args: + value: The duration to parse. + + Returns: + The number of milliseconds in the duration. + """ if isinstance(value, int): return value second = 1000