Fix for non-signal-safe thrift socket polling
Fix for non-signal-safe thrift socket polling

Summary: The select.epoll().poll() and select.select() functions instantiate a "long" syscalls (poll(2) and select(2), respectively), which unlike "short" syscalls (which simply block all signals) will get interrupted by any incoming signal.  Usually this is fine, but interrupted syscalls don't complete, and rather return an error with errno set to EINTR, which in turn causes Python to raise an OSError.  This would cause any thrift client using TSocket.py to crash and burn horribly if it used signals anywhere (e.g. for timeouts implemented by SIGARLM, such as used by the python Queue classes).  See  http://bugs.python.org/issue17097 for the change that makes this automatic in python 3.3.

Test Plan: Verify pass all unit tests, verify thrift clients no longer die horribly when receiving signals during the thrift select() and poll() calls

Reviewed By: ajitb@fb.com

Subscribers: ruibalp, alandau, bmatheny

FB internal diff: D1378506

Tasks: 4497957

fengshao0907/fbthrift,jesboat/fbthrift,HankFaan/fbthrift,raphaelamorim/fbthrift,facebook/fbthrift,sinjar666/fbthrift,Orvid/fbthrift,Orvid/fbthrift,project-zerus/fbthrift,getyourguide/fbthrift,raphaelamorim/fbthrift,uber/fbthrift,kangkot/fbthrift,guker/fbthrift,kangkot/fbthrift,jesboat/fbthrift,LinusU/fbthrift,Orvid/fbthrift,kangkot/fbthrift,jesboat/fbthrift,jesboat/fbthrift,fengshao0907/fbthrift,kangkot/fbthrift,facebook/fbthrift,maxwell-demon/fbthrift,uber/fbthrift,project-zerus/fbthrift,raphaelamorim/fbthrift,LinusU/fbthrift,soumith/fbthrift,chjp2046/fbthrift,chjp2046/fbthrift,HankFaan/fbthrift,soumith/fbthrift,facebook/fbthrift,chjp2046/fbthrift,fengshao0907/fbthrift,getyourguide/fbthrift,uber/fbthrift,soumith/fbthrift,uber/fbthrift,guker/fbthrift,uber/fbthrift,guker/fbthrift,SergeyMakarenko/fbthrift,chjp2046/fbthrift,maxwell-demon/fbthrift,project-zerus/fbthrift,chjp2046/fbthrift,HankFaan/fbthrift,fengshao0907/fbthrift,Orvid/fbthrift,jesboat/fbthrift,Orvid/fbthrift,soumith/fbthrift,sinjar666/fbthrift,guker/fbthrift,project-zerus/fbthrift,guker/fbthrift,HankFaan/fbthrift,jesboat/fbthrift,sinjar666/fbthrift,jesboat/fbthrift,soumith/fbthrift,kangkot/fbthrift,LinusU/fbthrift,HankFaan/fbthrift,Orvid/fbthrift,facebook/fbthrift,kangkot/fbthrift,soumith/fbthrift,project-zerus/fbthrift,chjp2046/fbthrift,raphaelamorim/fbthrift,SergeyMakarenko/fbthrift,facebook/fbthrift,guker/fbthrift,maxwell-demon/fbthrift,facebook/fbthrift,getyourguide/fbthrift,jesboat/fbthrift,project-zerus/fbthrift,soumith/fbthrift,chjp2046/fbthrift,HankFaan/fbthrift,project-zerus/fbthrift,fengshao0907/fbthrift,kangkot/fbthrift,Orvid/fbthrift,uber/fbthrift,maxwell-demon/fbthrift,raphaelamorim/fbthrift,guker/fbthrift,project-zerus/fbthrift,SergeyMakarenko/fbthrift,chjp2046/fbthrift,sinjar666/fbthrift,guker/fbthrift,getyourguide/fbthrift,guker/fbthrift,getyourguide/fbthrift,LinusU/fbthrift,fengshao0907/fbthrift,facebook/fbthrift,uber/fbthrift,maxwell-demon/fbthrift,soumith/fbthrift,Orvid/fbthrift,getyourguide/fbthrift,facebook/fbthrift,getyourguide/fbthrift,SergeyMakarenko/fbthrift,chjp2046/fbthrift,LinusU/fbthrift,sinjar666/fbthrift,HankFaan/fbthrift,uber/fbthrift,HankFaan/fbthrift,LinusU/fbthrift,chjp2046/fbthrift,sinjar666/fbthrift,maxwell-demon/fbthrift,Orvid/fbthrift,project-zerus/fbthrift,sinjar666/fbthrift,jesboat/fbthrift,SergeyMakarenko/fbthrift,SergeyMakarenko/fbthrift,sinjar666/fbthrift,SergeyMakarenko/fbthrift,uber/fbthrift,SergeyMakarenko/fbthrift,raphaelamorim/fbthrift,LinusU/fbthrift,HankFaan/fbthrift,fengshao0907/fbthrift,getyourguide/fbthrift,maxwell-demon/fbthrift,LinusU/fbthrift,jesboat/fbthrift,sinjar666/fbthrift,uber/fbthrift,LinusU/fbthrift,jesboat/fbthrift,sinjar666/fbthrift,project-zerus/fbthrift,LinusU/fbthrift,getyourguide/fbthrift,SergeyMakarenko/fbthrift,kangkot/fbthrift,project-zerus/fbthrift,kangkot/fbthrift,soumith/fbthrift,maxwell-demon/fbthrift,getyourguide/fbthrift,kangkot/fbthrift,chjp2046/fbthrift,HankFaan/fbthrift,LinusU/fbthrift,raphaelamorim/fbthrift,fengshao0907/fbthrift,SergeyMakarenko/fbthrift,SergeyMakarenko/fbthrift,raphaelamorim/fbthrift,soumith/fbthrift,raphaelamorim/fbthrift,Orvid/fbthrift,sinjar666/fbthrift,uber/fbthrift,maxwell-demon/fbthrift,HankFaan/fbthrift,guker/fbthrift,raphaelamorim/fbthrift,raphaelamorim/fbthrift,uber/fbthrift,Orvid/fbthrift,soumith/fbthrift,SergeyMakarenko/fbthrift,maxwell-demon/fbthrift,fengshao0907/fbthrift,jesboat/fbthrift,kangkot/fbthrift,getyourguide/fbthrift,guker/fbthrift,fengshao0907/fbthrift,chjp2046/fbthrift,facebook/fbthrift,maxwell-demon/fbthrift,project-zerus/fbthrift,getyourguide/fbthrift,fengshao0907/fbthrift