Три способа выполнить множество задач с asyncio
Функция для примера:
async def do_it(n):
await asyncio.sleep(random.uniform(0.5, 1))
return n
1. Последовательный вызов
async def main():
for i in range(100):
result = await do_it(i)
Такой вызов имеет смысл только тогда, когда результат одной задачи требуется для вызова следующей.
Если они независимы, то это антипаттерн, так как аналогичен простому синхронному вызову по очереди.
2. Упорядоченный результат
async def main():
tasks = [do_it(i) for i in range(100)]
results = await asyncio.gather(*tasks)
Выполняет корутины конкурентно и возвращает результат в виде списка.
Полезен когда требуется получить результаты в том же порядке в котором задачи отправлены.
3. Результат по мере готовности
tasks = [asyncio.create_task(do_it(i)) for i in range(100)]
for cor in asyncio.as_completed(tasks):
result = await cor
Так же выполняет корутины конкурентно, но не гарантирует порядок. Результат возвращается по мере готовности, каждый отдельно.
Полезен когда нужно обработать любой ответ как можно скорее.
#async
#ARDR/USDT analysis :
#ARDR is in a bearish trend, consistently making lower lows (LLs) and lower highs (LHs) below the 200 EMA. The price is currently rejecting from the 200 EMA and is anticipated to resume its downward movement, targeting lower levels.
TF : 4H
Entry : $0.07035
Target : $0.05818
SL : $0.07815
#ARDR👈
https://www.binance.com/en/trade/ARDR_BTC
Buying Zone 540-550👈
Buy in parts n successive dips
Strictly follow as directed
On the verge of hardcore pump
Sell
🤑 620-650
🤑 650-700
🚀 700-800
💃 800-900 & above
#ARDR/USDT analysis :
After breaking out above the 200 EMA, the #Ardor has retested it and consolidated sideways over the support zone. Recently, the price has bounced back from the support zone, and it is anticipated to continue its bullish momentum to test the previous swing high level.
TF : 1D
Entry : $0.09132
Target : $0.12550
SL : $0.07356
Roaring Kitty Hints at Comeback
🐦 Roaring Kitty, a key figure in the GameStop stock surge, teases a return. His recent tweet features a video, sparking nostalgia and speculation about upcoming moves. Kitty symbolizes retail investor resistance against Wall Street, igniting the meme stock revolution in 2021.
🔗Roaring Kitty's tweet
🔗 Whale Alert: $102M in #BTC transferred Details here
🔗 Bithumb launches new ARDR & QKC trading Read more
#GameStop#RoaringKitty#memeStocks#BTC#Crypto#VC#RetailInvestors#WhaleAlert#SouthKorea#Trading#Bithumb#ARDR#QKC#Investing#MarketNews#Finance#Nostalgia#Tease#Speculation