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

Резултати

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

Пребарај: #mujoco

当前筛选 #mujoco清除筛选
GitHub Trends

@githubtrending · Post #14744 · 24.05.2025 г., 00:00

#jupyter_notebook#mujoco#physics#robotics MuJoCo is a powerful physics engine that helps researchers and developers simulate complex movements and interactions, especially in robotics and machine learning. It provides fast and accurate simulations, which are crucial for understanding how objects move and interact with their environment. MuJoCo is beneficial because it allows users to create realistic models of multi-joint systems, compute both forward and inverse dynamics, and even handle contacts and constraints effectively. This makes it a valuable tool for those working in fields like robotics, biomechanics, and animation[1][2][5]. https://github.com/google-deepmind/mujoco

GitHub Trends

@githubtrending · Post #15225 · 15.10.2025 г., 13:00

#mdx#bilateral_teleoperation#force_feedback#genesis#gravity_compensation#humanoid_robot#imitation_learning#machine_learning#moveit2#mujoco#open_source#openarm#python#reinforcement_learning#robot#robot_arm#robotics#ros2#teleoperation OpenArm is a special robot arm that helps with physical AI research. It has 7 degrees of freedom, which means it can move like a human arm. This makes it good for tasks that involve touching or moving things safely around people. The robot is open-source, meaning anyone can build, modify, and use it. This is helpful because it makes advanced robotics available to more people, like researchers and students, without costing too much. A complete system with two arms costs about $6,500, which is much cheaper than similar robots. https://github.com/enactic/openarm