Skip to content

Commit

Permalink
add utils.unix_rlimit
Browse files Browse the repository at this point in the history
  • Loading branch information
lidong committed Jun 29, 2024
1 parent a9a78fc commit b8aad05
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion morebuiltins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.0"
__version__ = "1.0.0"
__all__ = [
"morebuiltins.utils",
"morebuiltins.date",
Expand Down
11 changes: 11 additions & 0 deletions morebuiltins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"get_paste",
"set_clip",
"switch_flush_print",
"unix_rlimit",
]


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b8aad05

Please sign in to comment.