Core, WebHost: lazy-load worlds in unpickler, WebHost and WebHostLib (#2156)

* Core: lazy-load worlds in unpickler

this should hopefully fix customserver's memory consumption

* WebHost: move imports around to save memory in MP

* MultiServer: prefer loading _speedups without pyximport

This saves ~15MB per MP and speeds up module import if it was built in-place.

* Tests: fix tests for changed WebHost imports

* CustomServer: run GC after setup

* CustomServer: cleanup exception handling
This commit is contained in:
black-sliver
2023-09-20 16:05:56 +02:00
committed by GitHub
parent 4a27fae1ab
commit d471dcc067
8 changed files with 93 additions and 75 deletions

View File

@@ -5,7 +5,8 @@ import json
class TestDocs(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
from WebHost import get_app, raw_app
from WebHostLib import app as raw_app
from WebHost import get_app
raw_app.config["PONY"] = {
"provider": "sqlite",
"filename": ":memory:",

View File

@@ -14,7 +14,8 @@ class TestFileGeneration(unittest.TestCase):
cls.incorrect_path = os.path.join(os.path.split(os.path.dirname(__file__))[0], "WebHostLib")
def testOptions(self):
WebHost.create_options_files()
from WebHostLib.options import create as create_options_files
create_options_files()
target = os.path.join(self.correct_path, "static", "generated", "configs")
self.assertTrue(os.path.exists(target))
self.assertFalse(os.path.exists(os.path.join(self.incorrect_path, "static", "generated", "configs")))