diff options
author | Erik Johnston <erik@matrix.org> | 2021-02-22 12:55:32 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2021-02-22 12:55:32 +0000 |
commit | 5d405f7e7a292691e30a33a762b7834d9854209b (patch) | |
tree | 40863c9e510ac4ad8aa2eada7bbdab6c9760cb27 /synapse/config/_base.py | |
parent | Merge remote-tracking branch 'origin/release-v1.28.0' into matrix-org-hotfixes (diff) | |
parent | Clean up the user directory sample config section (#9385) (diff) | |
download | synapse-5d405f7e7a292691e30a33a762b7834d9854209b.tar.xz |
Merge remote-tracking branch 'origin/develop' into matrix-org-hotfixes
Diffstat (limited to 'synapse/config/_base.py')
-rw-r--r-- | synapse/config/_base.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py index 97399eb9ba..e89decda34 100644 --- a/synapse/config/_base.py +++ b/synapse/config/_base.py @@ -21,7 +21,7 @@ import os from collections import OrderedDict from hashlib import sha256 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 @@ -147,7 +147,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 |