AsyncIO & Asynchronous Programming in Python

  Рет қаралды 146,926

NeuralNine

NeuralNine

Күн бұрын

In this video we learn about asynchronous programming in Python. We will talk about the keywords async and await.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
💻 The Algorithm Bible Book: www.neuralnine.com/books/
🐍 The Python Bible Book: www.neuralnine.com/books/
👕 Programming Merch: www.neuralnine.com/shop
💻 Exclusive Content 💻
👥 Patreon: / neuralnine
🌐 Social Media & Contact 🌐
📱 Website: www.neuralnine.com/
📷 Instagram: / neuralnine
🐦 Twitter: / neuralnine
🤵 LinkedIn: / neuralnine
📁 GitHub: github.com/NeuralNine
🤵 Personal Profile: / floriandedov
🎵 Outro Music From: www.bensound.com/

Пікірлер: 133
@neelbanga
@neelbanga 3 жыл бұрын
Hello! I have a very small programming channel, I was wondering if you had any tips for me? Thank you!
@NeuralNine
@NeuralNine 3 жыл бұрын
Just took a look. Great English skills, are you a native speaker? Regarding tips I can just say the usual stuff. Upload good videos on a regular basis. Make the titles catchy but not Scammy. Make the thumbnails catchy but not ridiculous. I think for some people age might be a factor because they don't want to learn from someone who is younger. In that case, patience will pay off. Besides that, just focus on learning and making videos on interesting projects and over time people will come to your channel. You seem like a good teacher. Good luck! :)
@NeuralNine
@NeuralNine 3 жыл бұрын
I just saw that you are doing this for one month. That is not a long time. You are doing quite well. Work hard, be creative but don't be impatient ^^
@neelbanga
@neelbanga 3 жыл бұрын
@@NeuralNine No, I'm not actually a native speaker, my first language was Hindi then Japanese and after that I learned English. I have used English the most and the longest though so that's why it's my best language! Thank you for the tips, I will keep all of them in mind! I'll also make sure to be patient!
@NeuralNine
@NeuralNine 3 жыл бұрын
@@neelbanga Wow impressive. Keep pushing, I think you will be successful! :) I will pin your comment. Maybe you will get some subs that way.
@neelbanga
@neelbanga 3 жыл бұрын
@@NeuralNine Thank you so much!!! I love your videos, BTW I’m subscribed, it means a lot to be pinned by you!!!
@hadi_ayoub
@hadi_ayoub 2 жыл бұрын
Even though I watched a lot of videos and read a lot of articles about asynchronous, I did not understand the mean idea of asynchronous until I watched the very first four minutes of your video. Great explanation! Thank you!
@MOFCrystal
@MOFCrystal 2 жыл бұрын
This is a crystal clear explanation with the easiest examples. I have watched a few clips before this about the same topic, but I could only get a vague idea about this concept. Now, I think I can use this for my code. Much appreciated.
@shiro3940
@shiro3940 Жыл бұрын
I was confused at the few first minutes but when you're at the returning section, things got much clearer. thanks! 👌
@MoisesRDL
@MoisesRDL Жыл бұрын
I read and watched videos without understanding, I found your video and understood everything. Great video, simple and well explained.
@Man-Vs-Car
@Man-Vs-Car 3 жыл бұрын
Love the lessons, thanks man, keep it up 👏🏽
@CarterCovers55
@CarterCovers55 2 жыл бұрын
Nice balance of explanation and elaboration, much appreciated!
@AmitabhSuman
@AmitabhSuman Жыл бұрын
Crisp and Clear! Perfect. Thanks a ton!
@damiankirstein3311
@damiankirstein3311 Жыл бұрын
Probably the best explanation of basic asyncio on YT
@asadcomputee3942
@asadcomputee3942 Жыл бұрын
Great video. It was easy to digest and it was fast to the point. Thank you!
@iaroslavdavydiak6439
@iaroslavdavydiak6439 8 ай бұрын
Thank you for explaining complicated things in simple words!
@Spiray
@Spiray 2 жыл бұрын
Wonderful explanation and great examples, thank you.
@matiascardenas6769
@matiascardenas6769 Жыл бұрын
Nice stuff, in a few minutes I was able to get a good idea of asyncio and clear quite some doubts. Thanks!
@viveksagarpandey6627
@viveksagarpandey6627 2 жыл бұрын
Easily explained with efficiency. Thanks man !!
@mrjt6404
@mrjt6404 9 ай бұрын
I have been studying asyncio for two weeks. I watched this video for the second time and now i think I understand this complex programming Thanks a lot❤
@jorge1869
@jorge1869 Жыл бұрын
Better explained impossible. I have seen other videos explaining this topic without understanding, but this guy is a crack. Subscribed!
@joshboye1427
@joshboye1427 2 жыл бұрын
Thank u very much man. Helped a lot. U explained it in a very elaborate and understandable way.
@yourfriendlyneighborhood5547
@yourfriendlyneighborhood5547 3 жыл бұрын
Keep going brother. Thank you so much for this channel and your videos ❤
@NeuralNine
@NeuralNine 3 жыл бұрын
thanks for watching :)
@spmathf
@spmathf 6 ай бұрын
exactly what I wanted. Great and simple explanation
@adityajha2553
@adityajha2553 3 ай бұрын
Very clean explanation, Thanks!
@dancorwin9232
@dancorwin9232 3 жыл бұрын
Excellent explainer for a beginner like me. Thanks man!
@SamirMamude
@SamirMamude 2 жыл бұрын
This is the best explanation about async/wait in Python, thank you buddy!
@user-mn1od5il7w
@user-mn1od5il7w 9 ай бұрын
That content is very helpful! Thank you for clarifying explanation!
@EnglishRain
@EnglishRain 2 жыл бұрын
Great explanation, thank you so much!
@coenfuse
@coenfuse 4 ай бұрын
Thanks man. Loved this video.
@o1techacademy
@o1techacademy Жыл бұрын
Excellent explanation of async await. Thank you very much sir.
@t3lls
@t3lls Жыл бұрын
Best video to the topic! Thank you!
@ksr11
@ksr11 2 жыл бұрын
Nicely explained. I watched other videos on same topic. But I got the real subject from this video only. Well understood difference between thread and asyncio.
@raizdesamauma8607
@raizdesamauma8607 9 ай бұрын
Great explanation, man, thanks a lot!
@yankunbigcat7925
@yankunbigcat7925 Жыл бұрын
well explained, thank you!
@debhasish
@debhasish Жыл бұрын
very nicely explained, Thank you for the tutorial
@moimiess
@moimiess 3 жыл бұрын
Awesome, just as I was looking into async you uploaded this. You helped alot, thank you! Btw: holy biceps!
@NeuralNine
@NeuralNine 3 жыл бұрын
thanks brother :D
@wakgate577
@wakgate577 2 жыл бұрын
Thx man it was very clear!
@PedroContipelli2
@PedroContipelli2 Жыл бұрын
Amazing explanation!
@benlong1062
@benlong1062 2 жыл бұрын
Thanks for this great explanation and example of async and await. I'd heard it mentioned a lot in other tutorials but never knew what it really meant.
@ds-yh1hl
@ds-yh1hl 2 жыл бұрын
Perfect video - definitely the easiest to follow explanation of this topic that I've seen so far. Thanks!
@aymancassim8944
@aymancassim8944 3 жыл бұрын
Great video as usual. Will it be possible for you to make a video on the abc library?
@nachoeigu
@nachoeigu 2 жыл бұрын
Wow, it is an amazing content. Thank you. I would like to know more about asyncio in Python. How did you learn it? Do you recommend some lecture or article?
@GelsYT
@GelsYT 2 жыл бұрын
THANK YOU! VERY CLEAR EXAMPLE😁
@miraclechielota3709
@miraclechielota3709 8 ай бұрын
very well explained Thanks so much
@pastet8950
@pastet8950 2 жыл бұрын
Saved my day, thanks.
@saurabhmahra4084
@saurabhmahra4084 2 жыл бұрын
Freaking amazing explanation!!
@mohammedabdelfattahgheffar3659
@mohammedabdelfattahgheffar3659 6 ай бұрын
Thank you this very helpful
@charan2446
@charan2446 3 жыл бұрын
I think its better to start a new channel or whatever maybe for BodyBuilding - NeuralFitness
@tobychen8832
@tobychen8832 Ай бұрын
Thank you for your nice video. I learned a lot from it.
@thedevnoteyt
@thedevnoteyt 3 жыл бұрын
Love watching ur videos ❤️🤘
@samthelamb0718
@samthelamb0718 3 ай бұрын
neuralnine coming in clutch AGAIN.
@srana977
@srana977 3 жыл бұрын
Well explained, I watched 7-8 videos before this and this is the best explanation. Great work. Would like to see more on Asyncio and also Go tutorials :)
@soumya32
@soumya32 9 ай бұрын
I am getting the error "partially initialized module 'asyncio' has no attribute 'run " . any solution?
@thelogs9434
@thelogs9434 3 жыл бұрын
u soo cool! Thanks to you, I'm starting to do small projects
@dontbetoxic4387
@dontbetoxic4387 3 жыл бұрын
wait thats awesome i want to learn the asyncio module because of your sockets video
@bouzie8000
@bouzie8000 3 ай бұрын
This was very very good
@OmidAtaollahi
@OmidAtaollahi 3 ай бұрын
helped a lot. tnx
@gri4on
@gri4on Жыл бұрын
Best explanation
@Duplicity75
@Duplicity75 Жыл бұрын
Great vid
@diegocassinera
@diegocassinera Жыл бұрын
You should have also printed time in millis along with the a b 1 2. Important note, even do the program had total sleep of 3 seconds, the actual total running time of the program is less.
@Bbdu75yg
@Bbdu75yg 8 ай бұрын
Amazing 🎉
@gus.stviaaa
@gus.stviaaa 3 жыл бұрын
I love your videos keep going
@alejandrorodriguezvelez2326
@alejandrorodriguezvelez2326 2 жыл бұрын
Hi, I need to make http requests to a REST API made in Flask from an app made in Tkinter. My question is if I need to use asyncIO to make the calls or is unnecessary in this case? The REST API was made to do CRUD operations connecting to a SQL database.
@AcidLite
@AcidLite Ай бұрын
Very good video.
@Ayoubased
@Ayoubased 2 жыл бұрын
thank you for the video, just stepped upon your channel and watched alot of videos. Idk why but I cant get my head around asynchronous programming. I know it is basically telling the process to stop wasting time and do something whenever ur waiting. But the implementation is hard for me to understand.
@lucaspinto5549
@lucaspinto5549 9 ай бұрын
You don't look nerdy but your lecturing was actually very good.
@msreeram8825
@msreeram8825 2 жыл бұрын
Man, I rarely subscribe to channels.. and you made me do it.. a sub from me♥️. Underrated content👌🏻
@judeleon8485
@judeleon8485 3 жыл бұрын
How does one get the return values when create_task has more than one function?
@yash1152
@yash1152 9 ай бұрын
7:17 hey, i just noticed. so; it means that control doesn't "await" as in pause till the completion of await.sleep right? while it waits for other "await"s? am i right?
@shilashm5691
@shilashm5691 2 жыл бұрын
Multithreading also does one thing at a time. It is also does the thing concurrently
@ShukyPersky
@ShukyPersky Жыл бұрын
what you have said to asynch programming describes precisely multithreading as well. In multithreading when a thread IOs and is waiting for stuff, another thread will get the CPU as GIL will be released
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
Threads preempt automatically, based on priorities or timeslice expiry. Coroutines only get preempted when they explicitly yield to other tasks. This makes for a simpler programming model.
@avivran1198
@avivran1198 Жыл бұрын
@@lawrencedoliveiro9104 It sounds like a very undeveloped multi-threading infrastructure that needs such a ridiculous mechanism RTOS kernels support it natively (including prioritizing threads which are not available with python GIL
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
@@avivran1198 Threads were very big in the 1990s. And sure, all modern OSes and languages support them. It’s just that we don’t always need their complications.
@nicovogelaar6427
@nicovogelaar6427 7 ай бұрын
Is it possible to share memory between two asynchronous tasks while they are running?
@Ariya1234gamer
@Ariya1234gamer 3 жыл бұрын
amazing i was asking myself how its possible :D
@NeuralNine
@NeuralNine 3 жыл бұрын
enjoy :D
@martajunk181
@martajunk181 4 ай бұрын
thank you for the video. I am not sure if your description of the difference between asyncio multithreading is accurate though. Aren't they generally about the same, i.e. concurrency (not parallelism) and the difference would be that in multithreading OS decides when to switch between the threads while in asyncio it is programmer themselves who indicates when it is safe to switch? I am by no means an expert in asynchronous/concurrent programming, so it is more a question than a decisive opinion
@HerozTech
@HerozTech 3 жыл бұрын
My personal hero
@ludovicobaldo8742
@ludovicobaldo8742 Жыл бұрын
What app do you use for coding?
@renataalmiratoth3110
@renataalmiratoth3110 11 ай бұрын
you can use the asyncros function for making a illusion of the mesages lagging but their not lagging
@jonsnow3513
@jonsnow3513 2 жыл бұрын
Hello what is your type of the mechanical switches , sound is impressive 🎷
@teeseus8822
@teeseus8822 2 жыл бұрын
at10:20 u could also just use f"{return_value = }"
@yuval1588
@yuval1588 Жыл бұрын
I think you're mistaken, "Asynchronous Programming" is a higher level concept that includes both multiprocessing and multithreading. Plus, i read that Asyncio is multithreading, but where the programmer chooses when to switch between threads.
@Stefkostov
@Stefkostov Жыл бұрын
good video
@mindedj2
@mindedj2 3 жыл бұрын
Is this a built in color profile or you have your own?
@troopekyt
@troopekyt 3 жыл бұрын
ValueError: Unrecognized type code -1 i am using a library called neuralintents to create an AI VIRTUAL VOICE ASSISTANT, but for some reason when i load the model i get that error? any ideas?
@troopekyt
@troopekyt 3 жыл бұрын
I beg you, answer me
@user-zi8jn1go8k
@user-zi8jn1go8k Жыл бұрын
Thanks for the video, I think I now got the idea HOW it works, but I don't get WHY should I use it? What is the advantage over plain old simple python threads? Python threads are also run concurrently but not in parallel. So it seems like all asyncio is achieving is the same result, just with extra jumping through the hoops with this async/await syntax garbage. While starting a regular thread is literally one line of code and you don't even need to modify the target function in any way. Is it all just to save a couple milliseconds and kilobytes used on creating a new thread?
@lawrencedoliveiro9104
@lawrencedoliveiro9104 Жыл бұрын
Because threads can be preempted at any time, they can lead to mysterious and hard-to-track-down timing-related bugs. Because coroutines only get preempted at the points where you explicitly allow them to, this keeps things simpler.
@yash1152
@yash1152 10 ай бұрын
4:58 > this is not very asynchrounos 5:30 > while [other] is sleeping, print b yeah; thtat's what i wanted 6:05 > once we have some idle time; we're going to run this task 6:19 it seems to me that asyncio _tends to_ perform only cpu-bound blocking task and skip over the non-cpu task unless awaited for 8:48 ret vals 10:40 > future in python; it's like a promise in javascript thanks a lot - i have been watching soo many videos, but none covered it his well... others went somewhat deep but still missed the point. u kept it to manageable but still covered the worthy concepts of returns etc... thanks a lot. ----- ```import asyncio async def main(): task = asyncio.create_task(otfn) print('a') await asyncio.sleep(1) print('b') ret_val = await task async def otfn(): print('1') await asyncio.sleep(2) print('2') return 10 asyncio.run(main())```
@MFM88832
@MFM88832 9 ай бұрын
Your code is buggy and doesn't work. Here is the fixed version: import asyncio async def main(): task = asyncio.create_task(otfn()) print('a') await asyncio.sleep(5) print('b') ret_val = await task print("Return value: ", ret_val) async def otfn(): print('1') await asyncio.sleep(2) print('2') return 10 asyncio.run(main())
@yash1152
@yash1152 9 ай бұрын
@@MFM88832 hi! the code was copy pasted from the video as far as i can think
@user-ee5dm2pv1z
@user-ee5dm2pv1z Ай бұрын
bro, this code snippet has proved very helpful in my project, but can you send me the code snippet if I want to print A,B,C asynchronously rather than A and B only, then ??????????????
@bretearwood7027
@bretearwood7027 Жыл бұрын
I've been coding for about 3 months now and my arms still aren't as big as yours.. what am I doing wrong?
@ameliabuns4058
@ameliabuns4058 10 ай бұрын
Why do this instead of just using actual threads/processes?
@joelrendon7775
@joelrendon7775 Жыл бұрын
Not getting the same results. makes hard to follow along/learn if I can't get the same results.
@ravirajkudal5626
@ravirajkudal5626 10 ай бұрын
Bro you got nice biceps ;)))))))
@ragd4L
@ragd4L 3 жыл бұрын
Does the program have 2 threads , one to execute and one to select which function to execute?
@dinimueterihrhurene2772
@dinimueterihrhurene2772 Жыл бұрын
cool
@Dan-wh2wv
@Dan-wh2wv Жыл бұрын
My question has noting to do with programming but is your arm real ?
@ShukyPersky
@ShukyPersky Жыл бұрын
It seems that this mechanism has too many quirks one should be aware if using it. like the one demonstrated on time 6:34 it seems that "task" was created. On one hand it was invoked though the main thread reached it end, while on the other hand it was invoked but due to release CPU when went sleeping the main thread existed not allowing the "task" to complete properly. This is insane, immature to be used.... kind of a joke Does anyone know a serious documentation on the web which thoroughly explains this mechanism ???? thanks
@RAM-im5lr
@RAM-im5lr 3 жыл бұрын
Waiting for Python ARCADE
@felixwurm1467
@felixwurm1467 Жыл бұрын
I hate asyncio, i think it's usles, it can't do anything better than normal Threads. I don't even feal that this ist easier. But your Video helped me understand.
@yesnonononoooop7920
@yesnonononoooop7920 3 жыл бұрын
OMG IM FIRST! Edit: NEURAL REPLIED ON MY COMMENT! I LOVE HIS VIDS
@NeuralNine
@NeuralNine 3 жыл бұрын
^^
@nirmaltheprogrammer510
@nirmaltheprogrammer510 3 жыл бұрын
finally 😃. still waiting for reinforcement learning edit : why no reply to me 😅
@__3093
@__3093 3 жыл бұрын
for the millionth time what's your intro song name lol
@troopekyt
@troopekyt 3 жыл бұрын
Have u ever heard of shazam u dumbass
@dontbetoxic4387
@dontbetoxic4387 3 жыл бұрын
start a fitness channel pl´z
@stormbytes
@stormbytes Жыл бұрын
You totally lost me. I never wrapped my head around this in Javascript either.
@avinashsah5456
@avinashsah5456 3 жыл бұрын
Seriously? No one notices his giant Biceps?
@lirimkusari626
@lirimkusari626 2 жыл бұрын
flori hmmmmmmmm, shiptar koka , e di une, sigg ,qin qin XD
@NeuralNine
@NeuralNine 2 жыл бұрын
I know shiptar means Albanian, but I am from Austria ^^
@lirimkusari626
@lirimkusari626 2 жыл бұрын
is Flori a common name in austria. First time i heard it outside of albania. Much love for the video ❤️.
@kavitharajni8962
@kavitharajni8962 3 жыл бұрын
im third!
@yesnonononoooop7920
@yesnonononoooop7920 3 жыл бұрын
ur fourth!
@trzztrzz2477
@trzztrzz2477 6 ай бұрын
pudden jiiz
Python Asynchronous Programming - AsyncIO & Async/Await
25:57
Tech With Tim
Рет қаралды 413 М.
Python Threading Explained in 8 Minutes
8:39
NeuralNine
Рет қаралды 122 М.
Can you beat this impossible game?
00:13
LOL
Рет қаралды 52 МЛН
Como ela fez isso? 😲
00:12
Los Wagners
Рет қаралды 32 МЛН
MOM TURNED THE NOODLES PINK😱
00:31
JULI_PROETO
Рет қаралды 21 МЛН
ДЕНЬ РОЖДЕНИЯ БАБУШКИ #shorts
00:19
Паша Осадчий
Рет қаралды 6 МЛН
Next-Level Concurrent Programming In Python With Asyncio
19:19
ArjanCodes
Рет қаралды 163 М.
Javascript Promises vs Async Await EXPLAINED (in 5 minutes)
5:50
Roberts Dev Talk
Рет қаралды 538 М.
Understanding Python: Asyncio
19:43
Jake Callahan
Рет қаралды 2,2 М.
Unlocking your CPU cores in Python (multiprocessing)
12:16
mCoding
Рет қаралды 291 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 348 М.
AsyncIO, await, and async - Concurrency in Python
9:12
Socratica
Рет қаралды 73 М.
Async for loops in Python
16:36
mCoding
Рет қаралды 56 М.
Python Asyncio, Requests, Aiohttp | Make faster API Calls
17:56
Patrick Collins
Рет қаралды 123 М.
Multiprocessing in Python
11:54
NeuralNine
Рет қаралды 101 М.
Где раздвижные смартфоны ?
0:49
Не шарю!
Рет қаралды 393 М.
ПК с Авито за 3000р
0:58
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,8 МЛН