e7299b17e9
Stack installed: - netfox v1.35.3 (core + extras + noray + internals) - godot-jolt v0.16.0-stable Architecture: - Server: ENet transport (works headless, no netfox deps) - Client/Editor: netfox rollback (RollbackSynchronizer, TickInterpolator) New/modified: - docs/migration-netfox-plan.md — migration architecture - scripts/network/network_manager.gd — netfox-aware ENet fallback - scripts/network/player.gd — clean base player - client/characters/player_netfox.gd — rollback player w/ WeaponManager - client/characters/input/player_net_input.gd — BaseNetInput subclass - client/characters/character/fps_character_controller.gd — netfox input feed - client/weapons/ — weapon data, registry, TacticalWeaponHitscan, WeaponManager - client/scripts/round_replicator.gd — client-side round state bridge - server/scripts/round_manager.gd — improved state machine - server/scripts/plugin_api/plugin_manager.gd — refined plugin system - config: enemy_tag, ally_tag for meatball targeting Removed: old C++ SimulationServer GDExtension (replaced by netfox rollback)
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
from collections.abc import AsyncGenerator
|
|
from contextlib import AbstractContextManager
|
|
from contextlib import asynccontextmanager as asynccontextmanager
|
|
from typing import TypeVar
|
|
|
|
import anyio.to_thread
|
|
from anyio import CapacityLimiter
|
|
from starlette.concurrency import iterate_in_threadpool as iterate_in_threadpool # noqa
|
|
from starlette.concurrency import run_in_threadpool as run_in_threadpool # noqa
|
|
from starlette.concurrency import ( # noqa
|
|
run_until_first_complete as run_until_first_complete,
|
|
)
|
|
|
|
_T = TypeVar("_T")
|
|
|
|
|
|
@asynccontextmanager
|
|
async def contextmanager_in_threadpool(
|
|
cm: AbstractContextManager[_T],
|
|
) -> AsyncGenerator[_T, None]:
|
|
# blocking __exit__ from running waiting on a free thread
|
|
# can create race conditions/deadlocks if the context manager itself
|
|
# has its own internal pool (e.g. a database connection pool)
|
|
# to avoid this we let __exit__ run without a capacity limit
|
|
# since we're creating a new limiter for each call, any non-zero limit
|
|
# works (1 is arbitrary)
|
|
exit_limiter = CapacityLimiter(1)
|
|
try:
|
|
yield await run_in_threadpool(cm.__enter__)
|
|
except Exception as e:
|
|
ok = bool(
|
|
await anyio.to_thread.run_sync(
|
|
cm.__exit__, type(e), e, e.__traceback__, limiter=exit_limiter
|
|
)
|
|
)
|
|
if not ok:
|
|
raise e
|
|
else:
|
|
await anyio.to_thread.run_sync(
|
|
cm.__exit__, None, None, None, limiter=exit_limiter
|
|
)
|