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
select
method allows us to provide a list of file descriptors. What is a file descriptor? - What does the
select
method do? What would happen to the provided file descriptors after callingselect
on them? - The manual said that the
select
method is 'synchronous I/O multiplexing'. What is multiplexing? In what way is theselect
method 'synchronous I/O multiplexing'? - How does the Python implementation of event loops make use of the
select
method?
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_once
method is polling for I/O. Does it polls for I/O by using the_select.select
method 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
,writer
variables 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