Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
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
Morphe
https://morphe.software
https://github.com/MorpheApp
Morphe is an Android app modification tool.
It allows you to change how apps work, look, and behave beyond their original design.
Build new functionality, remove limitations, and tailor apps to your needs.
For now it supports these censored apps: YouTube, YouTube Music or Reddit.
You should boycott them, but if you are used by those propaganda apps, at least you could remove the unwanted ads
Morphe is an independent project based on prior work from ReVanced.
#yt
⚡️You-Get: Download video, audio, images from the web easily!
Ever wanted to pull a bunch of content down so you can watch later?
You-Get is a CLI (command line interface) utility that makes it easy to download videos, audio, and images from the web.
https://you-get.org
you-get 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
You Get supports an impressive array of sites: Youtube, Twitter, VK, Tumblr, Soundcloud, Instagram, Facebook, and countless others!
It supports downloading YouTube playlists as well, it'll go through each video in the playlist.
Downloads can be very slow though, I recommend you use the —info flag before downloading to see what formats are available. Then you can run the command again with the —i-tag flag at whichever quality level is right for you.
You can download videos off of big tech platforms / paywalls by using the '—cookies' flag and pointing to a Firefox cookies database (cookies.sqlite).
Alternative: https://ytdl-org.github.io/youtube-dl/
🫶@takebackourtech
#yt
#NewPipe on #Linux, Using Android_translation_layer
https://flathub.org/apps/net.newpipe.NewPipe
Comments
https://news.ycombinator.com/item?id=41963932
#yt
yt-fts - YouTube Full Text Search
https://github.com/NotJoeMartinez/yt-fts
yt-fts is a command line program that uses yt-dlp to scrape all of a #YouTube channels #subtitles and load them into a sqlite database that is searchable from the command line. It allows you to query a channel for specific key word or phrase and will generate time stamped YouTube urls to the video containing the keyword.
It also supports semantic search via the OpenAI embeddings API, Gemini embedding API and using chromadb.
Blog Post
LLM/RAG Chat Bot
Video Summaries
Semantic Search
CHANGELOG
Installation:
pip install yt-fts
#yt
SmartTube
Advanced player for set-top boxes and tvs running Android OS
Features
No Ads
Designed for TV screens
Up to 8K video resolution
Login into your account
Cast from the phone
Support tv box remote controller
Support external software keyboard
Support devices without Google Services
Open source
https://smarttubeapp.github.io
https://github.com/yuliskov/SmartTube
https://github.com/yuliskov/SmartTube/releases
WARNING NOT FULLY OPEN SOURCE
There are at least 5 proprietary libraries in the app.
https://github.com/yuliskov/SmartTube/issues/471
* Crashlytics (/com/crashlytics): Tracking
* Firebase Data Transport (/com/google/android/datatransport): NonFreeNet
* Google Mobile Services (/com/google/android/gms): NonFreeDep
* Firebase (/com/google/firebase): NonFreeNet,NonFreeDep
* Firebase Analytics (/com/google/firebase/analytics): Tracking
IzzySoft:
The 5 offenders are not permitted at F-Droid (and before you ask: I wouldn't take it into my repo either unless at least Crashlytics and Firebase Analytics are removed; 5 non-free libraries is a bit much for free/libre software).
#video#yt#androidtv
Latest release Freetube - An electron Youtube client that blocks ads (but can't avoid Google's YouTube censorship) now comes with support for sponsorblock
https://github.com/FreeTubeApp/FreeTube/releases/tag/v0.13.0-beta
#freetube#yt#YouTube