From fab6a54ff8ceb68c2869d31647f65f8b026c2ef9 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sun, 10 May 2020 13:12:09 -0700 Subject: [PATCH 1/2] Fixed paths issue with server script --- .idea/dictionaries/ericf.xml | 1 + assets/src/server/ballisticacore_server.py | 25 +++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 4e45609f..3fa055ba 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -319,6 +319,7 @@ cnode codecsmodule codefilenames + codefiles codehash codeop collapsable diff --git a/assets/src/server/ballisticacore_server.py b/assets/src/server/ballisticacore_server.py index 926043b5..969d5884 100755 --- a/assets/src/server/ballisticacore_server.py +++ b/assets/src/server/ballisticacore_server.py @@ -31,22 +31,19 @@ from pathlib import Path from threading import Lock, Thread, current_thread from typing import TYPE_CHECKING +# We make use of the bacommon and efro packages as well as site-packages +# included with our bundled Ballistica dist, so we need to add those paths +# before we import them. +sys.path += [ + str(Path(Path(__file__).parent, 'dist', 'ba_data', 'python')), + str(Path(Path(__file__).parent, 'dist', 'ba_data', 'python-site-packages')) +] + from bacommon.servermanager import ServerConfig, StartServerModeCommand from efro.dataclasses import dataclass_assign, dataclass_validate from efro.error import CleanError from efro.terminal import Clr -# We change our working directory according to file's path -# so that the script can be properly executed from anywhere -os.chdir(os.path.abspath(os.path.dirname(__file__))) - -# We make use of the bacommon and efro packages as well as site-packages -# included with our bundled Ballistica dist. -sys.path += [ - str(Path(os.getcwd(), 'dist', 'ba_data', 'python')), - str(Path(os.getcwd(), 'dist', 'ba_data', 'python-site-packages')) -] - if TYPE_CHECKING: from typing import Optional, List, Dict, Union, Tuple from types import FrameType @@ -54,7 +51,7 @@ if TYPE_CHECKING: # Not sure how much versioning we'll do with this, but this will get # printed at startup in case we need it. -VERSION_STR = '1.0' +VERSION_STR = '1.0.1' class ServerManagerApp: @@ -432,6 +429,10 @@ class ServerManagerApp: def main() -> None: """Run a BallisticaCore server manager in interactive mode.""" try: + # Change our working directory according to file's path + # so that this script can be run from anywhere. + os.chdir(os.path.abspath(os.path.dirname(__file__))) + ServerManagerApp().run_interactive() except CleanError as exc: # For clean errors, do a simple print and fail; no tracebacks/etc. From c3b5a8807c5d04ee3f57f98bbe07a058804c28b5 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Sun, 10 May 2020 13:16:51 -0700 Subject: [PATCH 2/2] Simplifying some thread pool worker counts to just use cpu_count --- tools/efrotools/code.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tools/efrotools/code.py b/tools/efrotools/code.py index 3b18a02d..387331c7 100644 --- a/tools/efrotools/code.py +++ b/tools/efrotools/code.py @@ -66,13 +66,8 @@ def formatcode(projroot: Path, full: bool) -> None: sys.stdout.flush() return {'f': filename, 't': duration} - # NOTE: using fewer workers than we have logical procs for now; - # we're bottlenecked by one or two long running instances - # so it actually helps to lighten the load around them. - # may want to revisit later when we have everything chopped up - # better - with concurrent.futures.ThreadPoolExecutor(max_workers=cpu_count() // - 2) as executor: + with concurrent.futures.ThreadPoolExecutor( + max_workers=cpu_count()) as executor: # Converting this to a list will propagate any errors. list(executor.map(format_file, dirtyfiles)) @@ -122,7 +117,7 @@ def cpplint(projroot: Path, full: bool) -> None: if result != 0: raise Exception(f'Linting failed for {filename}') - with ThreadPoolExecutor(max_workers=cpu_count() // 2) as executor: + with ThreadPoolExecutor(max_workers=cpu_count()) as executor: # Converting this to a list will propagate any errors. list(executor.map(lint_file, dirtyfiles)) @@ -178,12 +173,7 @@ def formatscripts(projroot: Path, full: bool) -> None: print(f'Formatted {filename} in {duration:.2f} seconds.') sys.stdout.flush() - # NOTE: using fewer workers than we have logical procs for now; - # we're bottlenecked by one or two long running instances - # so it actually helps to lighten the load around them. - # may want to revisit later when we have everything chopped up - # better - with ThreadPoolExecutor(max_workers=cpu_count() // 2) as executor: + with ThreadPoolExecutor(max_workers=cpu_count()) as executor: # Convert the futures to a list to propagate any errors even # though there are no return values we use. list(executor.map(format_file, dirtyfiles))