Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
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
MRKT: Exciting Holiday Boost 2025 Prize Pool
#collectibles#prize
The MRKT channel announces the impressive Holiday Boost 2025 prize pool featuring rare collectibles. Among these are several Heart Lockets and a unique "Valentine" edition with only 1% rarity.
Source: link
@tonlines
🎁Introducing a quick draw from TON Events!
Right now our partner BroBot is hosting a contest with the participation of 💥EVAA and Bemo — the contest #prize pool is huge, but few people qualified to participate, so the chances of winning are quite high.
How to get a prize from BroBot:
🟨Go to the bot
🟨 Connect your wallet (MyTonWallet or Tonkeeper)
🟨 Pass the daily captcha (at least 3 times)
🟨 Stake 1 TON on Bemo
🟨 We add 1 stTON to EVAA to the supply
How to receive a prize from us:
🟨Share a story on your profile
🟨 Send to our chat a screenshot of completed task No. 4 of the BroBot conest and your wallet below.
🟨 Receive 1 $TON from us to your wallet after the end of the contest
Hurry up! 11 days left until the end of the #contest🔥
#BroBot#EVAA#Bemo#TonEvents
Hey Freelancers 🕹!
🆕Exciting updates on our Telegram Mini App! Here’s what’s new:
👍No More Tapping for Points: Compete fairly without autoclickers! Claim your reward every 8 hours (or more often if you wish).
👊New Match-Making System: Now you’ll compete with players of similar levels for a balanced experience.
👨💻Minor UX/UI Improvements: We've made some tweaks for a smoother user experience.
And stay tuned, because we’re preparing a BIG update for you this week. Get ready!
Pixelverse — You’re the game changer.
#pixelverse#crypto#ton#taptap#game#blum#hot#not#giveaways#prize
https://t.me/pixelversexyzbot👈👈
°
GM ALL! 👍
Don't forget to get on our bot and earn Fi points! We farm all day. Don't forget to get on our Telegram bot and earn Fi points! We farm all day.
https://t.me/pixelversexyzbot👈
#pixelverse#crypto#ton#taptap#game#blum#hot#not#giveaways#prize
How to get Degen SBT Airdrop
The Degen airdrop aims to reward users of TON #DeFi projects, including liquid staking, lending, Perp DEX, vaults, derivatives, and launchpads.
Step 1: Get the Degen Badge
🚬 The first step is to claim your Degen Badge. This is your Soul-Bound Token, which proves your participation in the Degen Airdrop. If you don’t mint the badge, your activity will not be tracked. Only the TVL and Volume you generate after claiming the Degen SBT will be counted.
Step 2. Liquidity and volumes
💎$100,000 forTVL Squad members
It is recommended to provide liquidity of at least $200 to projects from the TVL Squad list to qualify for a reward, but not less than $1. The best projects will receive additional prizes for their communities.
and/or
💎$100,000 forVolume Squad members
It is recommended to provide trading volumes of $1000 in Volume Squad to qualify for a reward, but not less than $1. The best projects will receive additional prizes for their communities.
🚀NFT League
NFT collection leaders, determined by the trading volume for the season, will provide additional prizes to their holders. [information to be confirmed]
Degen Airdrop prize pool
Users who complete the above actions will share $200,000 in #Degen airdrop, as well as additional prizes from top NFT collections. The maximum reward per wallet is set at $1,000 in Toncoin.
League Members
💎SettleTON
💎TON Hedge
💎DAOLama
💎Parraton
💎Tradoor
Full list of participants
Degen is an abbreviation of the word "degenerate". It is usually used to describe people who engage in speculative crypto trading or very high-risk digital asset investments.
Despite the negative connotations, members of the crypto community may view the title of “degen” as an achievement, as it demonstrates a willingness to take risks and a desire to participate in the development of the crypto industry.
Well, you get the hint... This activity is only for Pro. If any terms from the post are unfamiliar or unclear to you, refrain from participating in this airdrop
#DYOR, #NFR
#NFT#SBT#TON#TheOpenLeague#airdrop#prize
🔠🅰️🔠🔠2️⃣
She spoke of her father’s “defensive racism”, which prompted him to throw a predatory white landlord down the stairs. She spoke of her mother’s insistence on integrating every new movie theatre in town.
She spoke of how when her “pitch-black” great-grandmother had first set eyes on Morrison and her sister, she said the girls had “been tampered with”, which was meant racially:
“We were not pure and she was.”
The dynamics of my mixed-race family didn’t match the norms, either. My black Zambian grandmother, for whom I’m named, initially disapproved of my mother’s decision to marry a white man; my mother’s older sister refused to attend the wedding.
Our moves to the UK and then to the US when I was a kid – with a year back in Zambia when I was a teenager – were punctuated by moments of racial absurdity:
“What are you? Black or white?” (As if I had a choice!) Yet even now, at my grown age, my first response to racism is surprise.
Despite our respective births in disparate times and places (Lorain, Ohio, in 1931; Lusaka, Zambia, in 1980), I think Morrison and I both lucked into the strange privilege of zooming out from or boomeranging around race.
This perhaps explains why neither of us tends to capitalise the word black when referring to people in writing. It concedes too much; it protests too much.
Morrison temperamentally disliked being pigeonholed. She was willing to accept “the labels” of race and gender only because, as she put it in a profile in the New Yorker, “being a black woman writer is not a shallow place but a rich place to write from. It doesn’t limit my imagination; it expands it.”
She often complained that literary criticism was unequipped to read black writing, which gets read as merely representative, in both the tokenistic and identitarian senses:
“Black literature is taught as sociology, as tolerance, not as a serious, rigorous art form,” she said.
Indeed, the ultimate source of Morrison’s renowned difficulty was not, I would submit, her prickly personality, her intersectional identity, or even her sometimes contrarian politics.
It was her commitment to reflecting the range and depth of black aesthetics – as epitomised by jazz, which she called “very complicated, very sophisticated, and very difficult” – in her own writing.
Her close friend, the writer Fran Lebowitz, said upon Morrison’s passing in 2019: “I know it sounds like a crazy thing to say, but I always thought Toni’s writing was underappreciated.
Because people always looked at it through the prism of her being black and being a woman. But Toni was a very experimental writer. There were a lot of things Toni did through her writing that just went unremarked upon.”
Many still dismiss Morrison’s stature as either undeserved or obvious, as if surely so much praise either begs the question or settles it.
They justify their disinclination to engage with the art itself by gesturing to what we might call her DEI-fication or her Oprah‑priation, as if Toni Morrison became Toni Morrison through some kind of literary affirmative action plan.
Morrison incensed all kinds of people. How dare she be a difficult writer and a black woman? How dare she refuse to placate or translate? How dare she demand to be taken seriously?
How dare she be a black artist with real ideas? How dare she ask that we actually read her writing, and on its own terms?
It could not have been easy to be Toni Morrison. Yet I aspire to it. I yearn for that freedom she so beautifully embodied: to feel at ease to be difficult.
#toni#morrison#zambia#nobel#prize#black#narratives
📱American Оbserver - Stay up to date on all important events
🇺🇸
How Did Toni Morrison Become Our National Archetype?
🔠🅰️🔠🔠1️⃣
There are many ways to be difficult in this world. You can be demanding, inconvenient, stubborn, complicated, troublesome, baffling, illegible.
Black womanhood is one place where all these forms of difficulty overlap. I feel like I have always known this; I have been called difficult more times in my life than I can count.
But I only began to understand – to discover the meanings and uses of – my own difficulty because of Toni Morrison.
Morrison has shaped the way we think about everything from literature to politics, criticism to ethics, to the responsibilities of making art.
In 1993 she became the only black woman ever to win the Nobel prize in literature. But the facts remain: she is difficult to read. She is difficult to teach.
Notwithstanding the voluminous train of profiles, reviews and scholarly analysis that she drags behind her, she is difficult to write about.
More to the point, she is our only truly canonical black female writer – and her work is highly complex.
In a 1981 Vogue profile, Morrison spoke of a reader who had “told her how difficult it was to understand black culture in her books – it was so removed from his experience”.
She had responded: “Boy, you must have had a hell of a time with Beowulf!” The Vogue interviewer, missing the wit in this retort, commented:
“Morrison has no patience with people who plead ignorance; but then, she does not pride herself on being a patient woman. ‘I find myself being more and more difficult,’ she says. ‘It’s something I really relish.’”
Morrison’s literary difficulty was often translated this way into a personal difficulty, a moral failing: How dare she be impatient! Well, wouldn’t you be?
One reason for Morrison’s air of pique was surely the strain of trying to balance the demands of multiple careers simultaneously. She was an editor, a professor, a writer, a critic and a public intellectual.
I have worked in these fields as well, so I know that extending many branches can be a way of distracting yourself from the core vocation.
The commitment to writing over all else is often viewed as selfish; when gender is factored into the equation, the charge can carry the stigma of illegitimacy.
“For a woman to say, ‘I am a writer’ is difficult,” Morrison noted succinctly.
Morrison’s childhood stories read like photo negatives of the standard American race narratives.
She struggled to accommodate these forms of often underpaid literary labour with the unpaid domestic labour of raising two sons as a single mother:
“It was very difficult writing and rearing children because they deserve all your time, and you don’t have it.”
This occupational difficulty was exacerbated not only by the fact that she was unique in her fields but also by the fact that she often wilfully chose to go it alone.
For example, she didn’t tell anyone at her first job in trade publishing that she was writing a novel until The Bluest Eye came out at another house.
As troublesome as difficulty may have been for her professionally, Morrison genuinely delighted in the difficulty of other black women artists, such as the novelist Gayl Jones, whose works she edited and published, and the jazz pianist and composer Mary Lou Williams.
For Morrison, the fact that they were considered difficult was a sign that they had insisted on their art being taken seriously.
To read Morrison herself with the seriousness that she deserves requires that we account for the knot – or bind – of gender and race she shared with them. It is not an easy one to untangle.
As Morrison wrote in a 1971 New York Times op-ed about feminism, “one must look very closely at the black woman herself – a difficult, inevitably doomed proposition, for if anything is true of black women, it is how consistently they have (deliberately, I suspect) defied classification”.
#toni#morrison#zambia#nobel#prize#black#narratives
📱American Оbserver - Stay up to date on all important events
🇺🇸