Let the user specify a custom loop across the asyncio API. Work around pending tasks upon closure.
Let the user specify a custom loop across the asyncio API. Work around pending tasks upon closure.

Summary: We should rather revisit how the lifecycle of a Thrift client should be managed by the end user. Currently the introduced workaround requires that the user calls `protocol.close()` when he's done with a client. Then we actually close the intermediate transports and cancel pending tasks (especially the SenderTransport consumer, which is otherwise looping forever). That was good enough for now.

Test Plan: Minimo works without writing stderr messages about pending tasks upon exit.

Reviewed By: haijunz@fb.com

Subscribers: alandau, bmatheny, mshneer, yfeldblum

FB internal diff: D1929799

Tasks: 5942102

Signature: t1:1929799:1427155031:b83c10422a40f093475f4556d08d4e6aee5f6a53

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