看到python捕获SIGINT event的文档,上面说signal这个包里的东西的功能是set handler for asynchronous event,于是背了下这两个词——asynchronous和synchronous,简称分别是async和sync,由于这两个词比较长,我们通常都用简称,而且发音也都正好不会破坏。
asynchronous: 美 [eɪ'sɪŋkrənəs]
synchronous: 美 ['sɪŋkrənəs]
以上音标来自dict.cn
Here is a minimal example program. It uses the alarm() function to limit the time spent waiting to open a file; this is useful if the file is for a serial device that may not be turned on, which would normally cause the os.open() to hang indefinitely. The solution is to set a 5-second alarm before opening the file; if the operation takes too long, the alarm signal will be sent, and the handler raises an exception.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|