I'm watching import asyncio: Learn Python's AsyncIO #2 - The Event Loop to try to understand the inner working of event loops. In the video, the instructor tried to explain this on the operating system level. However, I know very few about operating systems and have a very hard time understanding his explanation.
Questions
At 9:46, the instructor showed a system calls manual about the select method.
- The instructor said that the
selectmethod allows us to provide a list of file descriptors. What is a file descriptor? - What does the
selectmethod do? What would happen to the provided file descriptors after callingselecton them? - The manual said that the
selectmethod is 'synchronous I/O multiplexing'. What is multiplexing? In what way is theselectmethod 'synchronous I/O multiplexing'? - How does the Python implementation of event loops make use of the
selectmethod?
At 11:11, the instructor showed a Windows Dev Center manual about 'I/O Completion Ports'.
- The instructor said that "if there are more events than available threads, some events will wait until one of threads in the pool frees up." So basically it works similarly to
concurrent.futures.ThreadPoolExecutor? - How does the Python implementation of event loops make use of 'I/O Completion Ports'?
At 22:31, the instructor showed the source code of _run_once method in base_events.py.
- The second step of
_run_oncemethod is polling for I/O. Does it polls for I/O by using the_select.selectmethod at line 1854 (24:41)?
At 25:30, the instructor showed the source code of _process_events method in selector_events.py.
- What do the
mask,selectors,reader,writervariables in the code refer to? What do they do?
Finally,
- What kinds of general computer science knowledge do I need to know in order to understand event loops?
from Understand the implementation of event loops in Python asyncio
No comments:
Post a Comment