TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #425 · 20 апр.

Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках. Выглядело это примерно так: from fastapi.concurrency import run_in_threadpool async def execute(data: DataRequest) -> DataResponse: try: result = await run_in_threadpool(sync_function, data) return DataResponse(data=result) except Exception as e: return DataResponse( error=str(e), success=False, ) В общем работает нормально. Для всех вызовов под капотом используется общий тредпул, всё работает предсказуемо. Но потребовалось изменить количество запускаемых в пуле потоков (по умолчанию создается 40 воркеров). Так как дело происходит с FastAPI, делается это через lifespan используя настройки anyio: import anyio @asynccontextmanager async def lifespan(app: FastAPI): limiter = anyio.to_thread.current_default_thread_limiter() limiter.total_tokens = 100 yield # если вдруг нужно вернуть обратно limiter.total_tokens = 40 Зачем менять количество воркеров? - уменьшить, если оперативки мало (один тред занимает ~8мб) - увеличить чтобы выдержать нагрузку Если есть предложения получше при тех же вводных - предлагайте😉 #async

Hashtags

Резултати

Пронајдени 1 слични објави

Пребарај: #unrealengine5

当前筛选 #unrealengine5清除筛选
GameDev News

@gamedevnewz · Post #16 · 09.07.2024 г., 12:31

👾Why Games on Unreal Engine 5 Are Indistinguishable from Reality 🎮 Not long ago, Unreal Engine 5 was released to the public, allowing everyone to try out the new features of the engine, the main ones being the new global illumination technology, Lumen, and the Nanite rendering system, which we will discuss now. The demos and games made on Unreal Engine 5 look truly impressive; in some cases, the graphics are indistinguishable from real life. Let's take a closer look at these technologies. Lumen is a fully dynamic global illumination and reflection system designed for use in Unreal Engine 5 on next-generation gaming consoles. By default, it is the global illumination and reflection system in UE 5. Lumen allows for diffuse interreflection with infinite bounces and indirect specular reflections in large, detailed environments that can scale from millimeters to kilometers. Nanite is a micro-polygon rendering system. With it, the PC does not render each model based on the number of its polygons. Thanks to this, images are rendered with a resolution of one polygon per pixel, meaning the higher the resolution of your monitor, the higher the number of polygons (detail of the model). Although, at the moment, the combined use of these technologies causes certain problems, for example with vegetation and other thin objects (Lumen degrades the quality of foliage rendered using Nanite). Of course, lighting and rendering alone are not enough when it comes to ultra-realistic graphics. Textures and the detail of the mesh itself play a significant role as well. #GameDevelopment#UnrealEngine5