Skip to content

Commit

Permalink
WebHost: Set Generator memory limit to 4GiB
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver committed Dec 1, 2024
1 parent b83b486 commit 20beaed
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions WebHostLib/autolauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ def launch_generator(pool: multiprocessing.pool.Pool, generation: Generation):


def init_db(pony_config: dict):
try:
import resource
except ModuleNotFoundError:
pass # unix only module
else:
# set soft limit for memory to 4GiB
soft_limit = 4294967296
old_limit, hard_limit = resource.getrlimit(resource.RLIMIT_AS)
resource.setrlimit(resource.RLIMIT_AS, (soft_limit, hard_limit))
logging.debug(f"Changed AS mem limit {old_limit} -> {soft_limit}")
del resource, soft_limit, hard_limit

db.bind(**pony_config)
db.generate_mapping()

Expand Down

0 comments on commit 20beaed

Please sign in to comment.