Python 3, an illustrated tour Transcripts
Chapter: Asynchronous Programming
Lecture: asyncio Tips and Tools
0:00 If you want to use asyncio you need to be aware
0:03 that your code needs to be infested or whatnot.
0:05 It needs to call await and use other code that allows you to wait
0:10 and run other code or is interruptable.
0:13 And so there are a bunch of libraries on GitHub
0:15 that are compatible with asyncio.
0:18 Tips for debugging you can use pdb to debug,
0:21 if you've tried to use pdb with threading, it can be a pain
0:25 because it may or may not stop and then it may be confusing
0:28 because Python is trying to run while you're trying to do pdb or whatnot.
0:31 But in this case because there's only one process running
0:36 you can use pdb to debug.
0:38 There's a couple other tools you might want to look into
0:40 these aren't included in the standard library, but they're there,
0:44 aioconsole and aiomonitor, these allow you
0:48 to have a repl that is asyncio aware
0:51 and allows you to directly call await and async coroutines
0:55 rather than having to put them into loops.
0:58 So it's a little bit easier to debug that way.
1:00 If you're doing testing you need to have an event loop
1:03 and your testing framework needs to be aware of that
1:06 so you can roll your own or if you don't want to roll your own
1:08 you can take advantage of stuff that's already there.
1:11 So there's one called asynctest, this is on top of the unit test framework
1:14 and there's another called pytest asyncio
1:17 which is compatible with pytest.
1:20 We've looked at a lot in this section.
1:22 We've talked about asyncio, what it means to be concurrent versus parallel
1:26 and how you can use non-blocking code to not wait if you're using asyncio.