rspivak / lsbaws

Let's Build A Web Server
MIT License
657 stars 304 forks source link

part3/webservice3e no occur errno.EINTR on maxos #13

Open zhwindy opened 5 years ago

zhwindy commented 5 years ago

test webservice3e.py with curl commands。There is no socket.error :[Errno 4] Interrupted system call when socket.accetp(). what happened ?

CliveUnger commented 2 years ago

I also failed to produced this error for websevice3e.py. My thought is that it only occurs when the interrupt happens during the .accept() part of the code, so catching that part exactly is hard to reproduce. The author thus shows the error as something that can potentially happen, although that is not made clear. Clarification would be greatly appreciated!

(I am running on WSL Ubuntu)

CliveUnger commented 2 years ago

Further discovery: I can reproduce the error with Python 2.7.17 but not Python 3.6.9. The code indicates it was test for Python 2.7.9 and Python 3.4. I imagine there was some update between Python 3.4 and 3.6.9 that changes the behavior of system interrupts while a socket is open.

Looks like PEP 475 included in Python 3.5 changed the behavior of how system call wrappers handle interrupts. They are now retried automatically.

zhwindy commented 2 years ago

emm...I'm almost forget this issue, time really flies