Automatically translated.View original post

How to write Python so that the boss doesn't complain slowly? 🤫

1/8 Edited to

... Read moreสำหรับใครที่เคยเขียน Python แบบซิงโครนัส หรือเรียก API ทีละตัว อาจจะเคยเจอปัญหาโค้ดทำงานช้า หรือโดนหัวหน้าบ่นเรื่องประสิทธิภาพไม่ดี ผมขอแชร์วิธีที่ช่วยแก้ไขปัญหานี้อย่างได้ผลจริงๆ คือการใช้ asyncio ซึ่งเป็นไลบรารีสำหรับเขียนโค้ดแบบอะซิงโครนัสใน Python โดยหลักการคือ เราจะสร้างฟังก์ชันที่รองรับการรอคอยงาน (async def) แล้วใช้ await เพื่อรอผลลัพธ์โดยไม่บล็อกงานอื่น และใช้ asyncio.gather() เพื่อสั่งงานหลายอย่างพร้อมกันแบบขนาน ทำให้เวลารอการตอบกลับ API ลดลงมาก จากเดิมที่ต้องรอทีละตัวเป็นนาที มาเหลือเพียงไม่กี่วินาที ผมลองเปรียบเทียบภาพยนตร์การเรียก API แบบเดิมที่ใช้เวลารวมกัน 3 นาที กับแบบใหม่ที่ใช้ asyncio พบว่าระบบทำงานเร็วขึ้นถึง 3 เท่า และทำให้โปรเจกต์เสร็จไวขึ้นมาก ไม่ต้องมาคอยทนรออีกต่อไป ลองนำไปประยุกต์ใช้ดูนะครับ จะช่วยให้คนที่ทำงานเกี่ยวกับ Python มีความคล่องตัวและประสิทธิภาพดีขึ้นอย่างเห็นได้ชัด นอกจากนี้ เทคนิคนี้ยังช่วยลดภาระของเครื่องเซิร์ฟเวอร์ในขณะที่รอการตอบสนองจาก API อีกด้วย ใครที่อยากก้าวสู่การเขียนโค้ด Python ระดับมือโปร ขอแนะนำให้เริ่มฝึกใช้ asyncio ตั้งแต่วันนี้ครับ!

Related posts

Want to earn more? Master these 4 skills in 2025
1. Copywriting Imagine getting paid to write captions, ads, or emails that MAKE MONEY for brands, ghat’s copywriting for you. Start by searching “How to write persuasive copy” on YouTube. Many creators share real-world tips for beginners. Example? Alex Cattoni or Gary Vee talk about creating catch
emilie.studygram

emilie.studygram

1551 likes

A page from an article titled "25 Things About Life I Wish I Had Known 10 Years Ago," featuring the first ten life lessons. Key advice includes embracing struggle, avoiding complaints, valuing loved ones, exercising daily, and not caring what others think.
A page from an article listing life lessons 11 through 20. Highlighted advice includes leading, understanding money's true importance, being nice, continuous learning, resting, not judging, thinking of others, and giving without expectation.
The final page of an article titled "25 Things About Life I Wish I Had Known 10 Years Ago," presenting life lessons 21 through 25. Key points include not taking oneself too seriously, avoiding blame, creating, learning from the past, and taking action.
25 Things About Life I Wish I Had Known 10 Yrs
25 Things About Life I Wish I Had Known 10 Yrs Ago #lifelessons #lifeadvice #maturity #lifequotes #Lemon8
It’s The Real Jay Anthony

It’s The Real Jay Anthony

616 likes

A study desk with an iPad, highlighter, textbook, and notes, featuring the title "How to get a 4.00 GPA Based on your Major" and "All majors included!".
Strategies for Business & Management Majors (Business Management, Accounting, Finance, Economics), including Active Participation, Case Study Analysis, Practice Financial Modeling, and Utilize Study Groups, with mentions of MarketingSherpa and GroupMe.
Strategies for Communications & Education Majors (Communications, Education), including Create Multimedia Presentations, Peer Teaching, Reflective Journaling, and Attend Workshops, with mentions of Canva and Notion.
Major-Specific Strategies to Achieve a ✨4.0 GPA✨🎓🧠
🎓1. Business & Management Majors (Business Management, Accounting, Finance, Economics) ✅Active Participation: Example: In a Marketing class, when discussing a case study like Coca-Cola’s rebranding, share your analysis of the marketing mix (4Ps). This not only engages you in the materi
Chalie_Baker

Chalie_Baker

7038 likes

A person at a desk with a laptop, reaching up, with the text 'Fun app for learning Coding Codebay' and the Codebay app icon, promoting a Python learning app.
A mobile app screen showing a Python lecture using a Terminator story scenario to teach the 'print' function, demonstrating interactive, story-based learning with a prompt to ask questions.
Mobile app screens displaying a coding exercise to debug Python code and a multiple-choice quiz, illustrating how the app includes quizzes and coding exercises for learning and assessment.
my favorite app for learning python 🫶
Plenty of people enjoy picking up a new language as a hobby, like Spanish or French... So, why not give learning a programming language a whirl? It could prove useful for work and also flex those computational thinking muscles. I stumbled upon this really interesting app. It's geared toward Pyt
Aura✨

Aura✨

528 likes

A person is shown coding at a desk in a dimly lit room, with a computer monitor displaying lines of code. The image features text overlay 'TOP 5 PROGRAMMING LANGUAGES FOR BEGINNERS' and a 'LEARN MORE' button, aligning with the article's theme of starting to code.
A computer setup displays a list of the 'TOP 5 PROGRAMMING LANGUAGES FOR BEGINNERS': Python, JavaScript, Java, C++, and Scratch. Each language includes a brief description and an icon, directly illustrating the article's main content.
A neon-lit desk setup features a computer displaying a purple galaxy wallpaper. An overlay asks, 'COMMENT IF YOU'LL TRY CODING IN 2025!', serving as a call to action related to the article's theme of learning to code.
2025 Is The Year You Learn How To Code 👾💜
Top 5 Programming Languages for Beginners Starting your coding journey can be overwhelming, but choosing the right language makes all the difference. Here are five beginner-friendly programming languages, each with its own strengths, to help you get started. Python is a favorite for beginners
CompSkyy

CompSkyy

60 likes

A desk setup with a computer monitor displaying an e-learning page, a white keyboard, an ergonomic mouse, and pens. The text overlay reads: "I don't have time to study".
A close-up of a pink 'Weekly Planner - Non-Dated' on a desk. The text overlay advises: "Use a Planner or Calendar Plan your week in advance to avoid last-minute stress."
A computer monitor displays the GeeksforGeeks website with various programming courses and topics. The text overlay states: "Break Down Tasks Tackle big assignments in smaller, manageable steps."
Think You Don’t Have Time To Study?
"I don’t have time to study!" Sound familiar? With so much to juggle, it’s easy to feel like there just aren’t enough hours in the day. But a little planning can make a huge difference! Swipe through for some simple tips to take control of your time. 🌸 → Use a Planner or Calendar: Planni
CompSkyy

CompSkyy

47 likes

Even a wiener has the right to complain about a delayed flight🥺✈️
#lifehack #moneyhacks #flight #airline
Budget wiener

Budget wiener

45 likes

Python Variable Names Explained (Avoid These Mista
Confused by Python code? 😵‍💫 The problem might be bad variable names. In this post, you’ll learn: ✔ What variable names are ✔ Rules you must follow ✔ Good vs bad examples ✔ Pro tips to write clean Python code Save this post 📌 and follow for more Python basics made easy 🐍✨ #Python #LearnPy
TechKeysX

TechKeysX

0 likes

This is was literally insane 😩 #fyp #italianvsamerican #foreignexchange #grwm #foreignexchangestudent
aves 🪩

aves 🪩

708 likes

I can’t complain !!! follow me on YouTube @jusbroc
#transman 💈🏳️‍⚧️💈
BROC ROMEO🏳️‍⚧️💈

BROC ROMEO🏳️‍⚧️💈

13 likes

How to land role in data/tech
Ask away any questions you may have 👇🏻 #dataanalytics #techjobs #careerdevelopment #career #jobtips
Ann

Ann

4 likes

Five Reasons you should never complain!
Five Reasons you should never complain! #fengshui #fengshuitips #complain #energy #energyhealing #fengshuisofia
sofia.fengshui

sofia.fengshui

68 likes

🚨WHY YALL NEVER COMPLAIN ABOUT THIS?
Bc why no one ever harass you when you’re doing all the wrong things?😵‍💫 • • • #healthyeating #fitnesshealth #gymgirl #fyp #gymworkout
thewealthyauntie

thewealthyauntie

28 likes

CNARC🎶🌞⛅️🌟🧡🦋

CNARC🎶🌞⛅️🌟🧡🦋

2 likes

Let’s complain less, be grateful more. 🫶🏾
Sister, there are people who went to sleep all over the world last night, poor and rich and white and black, but they will never wake again. Sister, those who expected to rise did not, their beds became their cooling boards, and their blankets became their winding sheets. And those dead folks would
PsychBae84

PsychBae84

13 likes

An image listing five free AI courses for beginners in 2024: Google's Introduction to Generative AI, Microsoft's Artificial Intelligence for Beginners, Harvard's Introduction to AI with Python, Coursera's Prompt Engineering for ChatGPT, and Coursera's AI for Everyone.
Details for Google's 'Introduction to Generative AI' course, showing the Google logo, course description, a link, and a visual breakdown of the learning path with three introductory modules on Generative AI, LLMs, and Responsible AI.
Details for Microsoft's 'Artificial Intelligence for Beginners' course, featuring the Microsoft logo, course description, a link, and a mind-map-like diagram illustrating various AI concepts like neural networks, deep learning, and knowledge representation.
🫶The hottest free AI courses for beginners🥰
📌 Tips: Skip the trial and access Coursera for free by following these steps: 1. Click "Enroll for Free" 2. Then click “Audit the course” 🔍 Discover the Best AI Learning Paths: 1. Google: Introduction to Generative AI Learning Path Google offers a 5-course program starting from scr
Valder

Valder

67 likes

MEN WITH MONEY NEVER COMPLAIN
sprinklesprinkle

sprinklesprinkle

50 likes

NBA Fans Complain Too Much
#lebronjames #wemby #nba #trending #fyp
RunningThroughReality

RunningThroughReality

0 likes

don't complain God is silent, open your Bible.
#fyp #god #jesus #podcast #motivation
Ana Rosa

Ana Rosa

2 likes

Lin Watchorn

Lin Watchorn

1 like

Python coding made easy with DeepSeek Chat! 🤖💻
#Python #Coding #AI #DeepSeek #haitiantiktok
JEFF JEUDY

JEFF JEUDY

14 likes

🎯 How to Manage Your Boss Like a Pro
Most people manage down. The smartest professionals learn to manage up — and it changes everything. ✅ The ALIGN method to build trust ✅ What your boss really wants but won’t say ✅ Power moves to boost your visibility & value ✅ How to spot a toxic boss before it’s too late Turn your bo
Steven Bou

Steven Bou

306 likes

The strong never complain about the environment.
Los Angeles enjoy life #loneliness
natural beauty

natural beauty

4 likes

Rep. Murphy: 'They just complain while we clean up the mess'
Rep. Murphy: 'They just complain while we clean up the mess'
TheAmericanBrief

TheAmericanBrief

154 likes

Book Recommendation for girlies 🌸🥰
#girlswhoread🌸 #girlbooks #selfhelpbooks #letsgotherebook
DM 💖 | Author💗🎀

DM 💖 | Author💗🎀

10 likes

A hand holds a light blue Bible with floral designs and light blue pom-poms along the spine. The text overlay reads "Bible Study Job 10-13" in a decorative font.
An open Bible displays pages for Job 10 and 11, featuring highlighted verses and handwritten notes. The notes summarize Job's complaints to God and Zophar's initial response, with various verses underlined.
An open Bible shows pages for Job 12 and 13, with highlighted text and handwritten annotations. The notes discuss Job's fourth speech, his response to Zophar, and his desire to argue his case with God.
Bible Study
Job 10-13 I’m following the bible study of Heart Dive on youtube. *the resources I used Enduring word #findgod🙏🏼📖 #readthebiblewithme #readingmybible #studythebiblewithme #readingthroughmybible
Angelis

Angelis

13 likes

A "Writing Ideas SYSTEM" for students is outlined, featuring steps like creating a personal idea bank, selecting from writing categories, daily idea warm-ups, and a plan for overcoming writer's block. It also shows a teacher's specific response to "I don't know what to write" and prompt cards.
How I FIXED ‘I don’t know what to write’
If your students constantly say “I don’t know what to write,” it’s NOT because they don’t have ideas—it’s because they don’t have a SYSTEM 👏🏽 I used to rely on cute brainstorming charts (they look great… but they don’t actually fix the problem 😅). What changed everything for me was switching to
𝐀𝐒𝐇𝐋���𝐄𝐘.

𝐀𝐒𝐇𝐋𝐄𝐘.

0 likes

Replying to @Han 🖤 📚 you’re right, Hannah. You have always seen me mask, because I always mask… I’m definitely not an anti-masker. ‘People’ (a very specific group of people) are making up a lot of nasty rumors about me. ❤️‍🩹 #greenscreen
Allison Tennyson

Allison Tennyson

2 likes

A spiral-bound notebook with lined paper and three pens (two black, one red) on top, with the text overlay "STEAL MY CHAPTER 9 SPANISH NOTES."
Handwritten Spanish vocabulary notes for "Capítulo 9: Recuerdos del Pasado," covering relationships, emotions, and life stages, with English translations, on a spiral-bound notebook page.
Handwritten Spanish vocabulary notes for "Capítulo 9" titled "Otros pasatiempos y diversiones," listing hobbies and activities with English translations, on a spiral-bound notebook page.
Chapter 9 Spanish Notes
These are my Spanish notes for chapter nine in my class. My plan was to take all of the vocabulary and write it down, then go through and take notes on the grammar section of my notes. • • • #letschat #education #student #college #notes
natalie

natalie

86 likes

life is too short to complain
#CapCut #fyp #inspiration #summerbod #embracevulnerability
Will

Will

19 likes

Women complain too much
Eric Mesi

Eric Mesi

57 likes

A laptop screen displays code for a Lemon8 analytics bot, with a small white robot figure in the foreground. The image has a text overlay that reads 'Coding Diary: Lemon8 Analytics Bot'.
A laptop screen shows Python code for web scraping. A Python logo is overlaid, with text stating 'Python: Easiest coding language to write scripts quickly'.
A laptop screen displays Python code. A Selenium WebDriver logo is overlaid, with text explaining it 'Opens chrome for me and downloads all my posts with analytics in just one click'.
Unlocking the algorithm: I coded a lemon8 BOT 🍋👩‍💻
Did some coding tonight, because I thought it'd be fun to webscrape the lemon8 website and look at my post analytics! 👾 What is Webscraping? 👾 Webscraping is coding a script to read information from a website and present it back in an organized manner. I wanted to get a nice organized li
starlight

starlight

32 likes

June 1st Energy: If you don’t lock in today, don’t complain in July 💅🏽
New month. New week. Same goals… but this time you actually show up for them. Girl, this is your reminder that motivation is cute, but discipline is what changes your life. Not tomorrow. Not when you “feel ready.” TODAY. Stop overthinking it. Stop restarting every Monday like it’s a reset but
Digital Taye 📲

Digital Taye 📲

5 likes

Who else is ready for these kids to go back to school ????????? #mom #momlife #momsoftiktok #backtoschool #contentcreator #viral #blowthisup #fyp
Joanna Roman

Joanna Roman

76 likes

Did the neighbors complain?😭 noo #gardening #lapolizia
Maria Jane

Maria Jane

0 likes

He doesn’t value me, he needs to change that
Do you feel like you’re doing too much that goes unappreciated in the relationship? If so, you’re probably putting focus on the wrong things, the things YOU think matter- but don’t matter to him as much. As a result you feel drained, undervalued, and hurt & he still has the audacity to comp
Ellie Lily

Ellie Lily

0 likes

can't complain about working if you work here
Flute guy

Flute guy

26 likes

Not going to complain about studying now.
Itsyoursimi

Itsyoursimi

2 likes

I usually don’t agree with things women say but she’s spot on with this video. Women who think everything is they bare minimum are the worst when it comes to dating. Because the moment you point out the bare minimum stuff on her end, the accountability gets lost quickly. #truth #accountability
KYWK_JWILL

KYWK_JWILL

13 likes

I can’t complain
One of the perks of owning a dessert shop #bakerylife #biz #entrepreneurlife #momlife #snowfall
The Ngear Family

The Ngear Family

2 likes

See more