diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bd73b6..361ff84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ -### 0.1.0 (2024-06-29) +### 1.0.0 (2024-06-29) 1. add `tk.TextWindow` -2. +2. add `utils.unix_rlimit` +3. release as the first stable version ### 0.0.9 (2024-06-26) 1. add `tk.TKit.ask_text` diff --git a/README.md b/README.md index 0cd7990..12b2b13 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,8 @@ print(morebuiltins.__file__) 1.25 `switch_flush_print` - Set builtins.print default flush=True. +1.26 `unix_rlimit` - Unix only. RLIMIT_RSS, RLIMIT_FSIZE to limit the max_memory and max_file_size + ## 2. morebuiltins.date diff --git a/doc.md b/doc.md index faa523f..f184b03 100644 --- a/doc.md +++ b/doc.md @@ -618,6 +618,15 @@ --- + +1.26 `unix_rlimit` - Unix only. RLIMIT_RSS, RLIMIT_FSIZE to limit the max_memory and max_file_size + +```python +``` + +--- + + ## 2. morebuiltins.date diff --git a/morebuiltins/__init__.py b/morebuiltins/__init__.py index 4b10607..9ae272c 100644 --- a/morebuiltins/__init__.py +++ b/morebuiltins/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.1.0" +__version__ = "1.0.0" __all__ = [ "morebuiltins.utils", "morebuiltins.date", diff --git a/morebuiltins/utils.py b/morebuiltins/utils.py index ae9a750..f952a18 100644 --- a/morebuiltins/utils.py +++ b/morebuiltins/utils.py @@ -57,6 +57,7 @@ "get_paste", "set_clip", "switch_flush_print", + "unix_rlimit", ] @@ -1111,6 +1112,16 @@ def flush_print(*args, **kwargs): builtins.print = flush_print +def unix_rlimit(max_mem, max_file_size): + "Unix only. RLIMIT_RSS, RLIMIT_FSIZE to limit the max_memory and max_file_size" + import resource + + if max_mem: + resource.setrlimit(resource.RLIMIT_RSS, (max_mem, max_mem)) + if max_file_size: + resource.setrlimit(resource.RLIMIT_FSIZE, (max_file_size, max_file_size)) + + if __name__ == "__main__": __name__ = "morebuiltins.utils" import doctest