Skip is_closing() check when not available.
Skip is_closing() check when not available.

https://github.com/bitcoin/bitcoin/pull/13715 introduced a new check
for _transport.is_closing() in mininode's P2PConnection's.  This function
is only available from Python 3.4.4, though, while Bitcoin is supposed
to support all Python 3.4 versions.

In this change, we make the check conditional on is_closing() being
available.  If it is not, then we revert to the behaviour before the
check was introduced; this means that
https://github.com/bitcoin/bitcoin/issues/13579 is not fixed for old
systems, but at least the tests work as they used to do before.

This includes a small refactoring from a one-line lambda to an
inline function, because this makes the code easier to read with more
and more conditions being added.

Fixes https://github.com/bitcoin/bitcoin/issues/13745.

bespike/litecoin,tjps/bitcoin,EthanHeilman/bitcoin,vertcoin/vertcoin,bitcoin/bitcoin,Bushstar/UFO-Project,FeatherCoin/Feathercoin,DigitalPandacoin/pandacoin,RHavar/bitcoin,lbryio/lbrycrd,FeatherCoin/Feathercoin,qtumproject/qtum,Christewart/bitcoin,jtimon/bitcoin,jtimon/bitcoin,domob1812/namecore,sipsorcery/bitcoin,myriadcoin/myriadcoin,instagibbs/bitcoin,anditto/bitcoin,vertcoin/vertcoin,sstone/bitcoin,domob1812/bitcoin,Kogser/bitcoin,Kogser/bitcoin,OmniLayer/omnicore,GlobalBoost/GlobalBoost,midnightmagic/bitcoin,lateminer/bitcoin,rnicoll/dogecoin,GroestlCoin/GroestlCoin,pataquets/namecoin-core,n1bor/bitcoin,DigitalPandacoin/pandacoin,digibyte/digibyte,bitcoinsSG/bitcoin,r8921039/bitcoin,jonasschnelli/bitcoin,OmniLayer/omnicore,kallewoof/bitcoin,jtimon/bitcoin,vertcoin/vertcoin,dscotese/bitcoin,cdecker/bitcoin,rnicoll/dogecoin,nikkitan/bitcoin,tjps/bitcoin,practicalswift/bitcoin,domob1812/bitcoin,monacoinproject/monacoin,pataquets/namecoin-core,Flowdalic/bitcoin,ElementsProject/elements,droark/bitcoin,n1bor/bitcoin,MarcoFalke/bitcoin,yenliangl/bitcoin,yenliangl/bitcoin,GroestlCoin/GroestlCoin,jambolo/bitcoin,myriadteam/myriadcoin,thrasher-/litecoin,rnicoll/bitcoin,qtumproject/qtum,CryptArc/bitcoin,ElementsProject/elements,BTCGPU/BTCGPU,fanquake/bitcoin,wellenreiter01/Feathercoin,Flowdalic/bitcoin,Flowdalic/bitcoin,lbryio/lbrycrd,r8921039/bitcoin,domob1812/namecore,RHavar/bitcoin,GlobalBoost/GlobalBoost,bitcoin/bitcoin,Sjors/bitcoin,sipsorcery/bitcoin,MeshCollider/bitcoin,JeremyRubin/bitcoin,EthanHeilman/bitcoin,achow101/bitcoin,andreaskern/bitcoin,ajtowns/bitcoin,sipsorcery/bitcoin,lbryio/lbrycrd,GlobalBoost/GlobalBoost,vmp32k/litecoin,bitcoinknots/bitcoin,kazcw/bitcoin,instagibbs/bitcoin,jnewbery/bitcoin,instagibbs/bitcoin,myriadteam/myriadcoin,DigitalPandacoin/pandacoin,fanquake/bitcoin,particl/particl-core,mitchellcash/bitcoin,qtumproject/qtum,mm-s/bitcoin,namecoin/namecore,particl/particl-core,ElementsProject/elements,myriadteam/myriadcoin,andreaskern/bitcoin,Kogser/bitcoin,Kogser/bitcoin,jamesob/bitcoin,anditto/bitcoin,namecoin/namecore,MeshCollider/bitcoin,bespike/litecoin,qtumproject/qtum,droark/bitcoin,thrasher-/litecoin,Sjors/bitcoin,wellenreiter01/Feathercoin,namecoin/namecore,Christewart/bitcoin,untrustbank/litecoin,practicalswift/bitcoin,jlopp/statoshi,EthanHeilman/bitcoin,bespike/litecoin,EthanHeilman/bitcoin,ElementsProject/elements,bitcoinknots/bitcoin,h4x3rotab/BTCGPU,mruddy/bitcoin,practicalswift/bitcoin,h4x3rotab/BTCGPU,CryptArc/bitcoin,kallewoof/bitcoin,monacoinproject/monacoin,FeatherCoin/Feathercoin,fujicoin/fujicoin,rnicoll/bitcoin,BTCGPU/BTCGPU,lbryio/lbrycrd,sstone/bitcoin,Xekyo/bitcoin,JeremyRubin/bitcoin,bitcoinsSG/bitcoin,guncoin/guncoin,thrasher-/litecoin,qtumproject/qtum,Xekyo/bitcoin,practicalswift/bitcoin,jonasschnelli/bitcoin,myriadteam/myriadcoin,thrasher-/litecoin,achow101/bitcoin,ajtowns/bitcoin,n1bor/bitcoin,domob1812/namecore,litecoin-project/litecoin,rnicoll/bitcoin,monacoinproject/monacoin,ahmedbodi/vertcoin,lateminer/bitcoin,andreaskern/bitcoin,domob1812/namecore,anditto/bitcoin,tecnovert/particl-core,lateminer/bitcoin,afk11/bitcoin,Kogser/bitcoin,jlopp/statoshi,sstone/bitcoin,ajtowns/bitcoin,droark/bitcoin,gjhiggins/vcoincore,pataquets/namecoin-core,Bushstar/UFO-Project,nikkitan/bitcoin,anditto/bitcoin,pstratem/bitcoin,fanquake/bitcoin,bitcoinknots/bitcoin,sipsorcery/bitcoin,pstratem/bitcoin,cdecker/bitcoin,anditto/bitcoin,h4x3rotab/BTCGPU,jlopp/statoshi,digibyte/digibyte,achow101/bitcoin,jlopp/statoshi,tecnovert/particl-core,mitchellcash/bitcoin,vmp32k/litecoin,guncoin/guncoin,FeatherCoin/Feathercoin,kazcw/bitcoin,untrustbank/litecoin,pataquets/namecoin-core,Christewart/bitcoin,droark/bitcoin,Bushstar/UFO-Project,jonasschnelli/bitcoin,GroestlCoin/bitcoin,jtimon/bitcoin,prusnak/bitcoin,FeatherCoin/Feathercoin,MeshCollider/bitcoin,fanquake/bitcoin,BTCGPU/BTCGPU,bitcoinsSG/bitcoin,jambolo/bitcoin,ElementsProject/elements,kallewoof/bitcoin,ericshawlinux/bitcoin,nikkitan/bitcoin,kazcw/bitcoin,Christewart/bitcoin,sstone/bitcoin,Kogser/bitcoin,bitcoin/bitcoin,jambolo/bitcoin,h4x3rotab/BTCGPU,yenliangl/bitcoin,alecalve/bitcoin,Bushstar/UFO-Project,CryptArc/bitcoin,peercoin/peercoin,alecalve/bitcoin,midnightmagic/bitcoin,AkioNak/bitcoin,qtumproject/qtum,tjps/bitcoin,n1bor/bitcoin,h4x3rotab/BTCGPU,jamesob/bitcoin,litecoin-project/litecoin,litecoin-project/litecoin,mm-s/bitcoin,pstratem/bitcoin,prusnak/bitcoin,dscotese/bitcoin,gjhiggins/vcoincore,OmniLayer/omnicore,kazcw/bitcoin,FeatherCoin/Feathercoin,namecoin/namecore,jambolo/bitcoin,untrustbank/litecoin,sipsorcery/bitcoin,ElementsProject/elements,gjhiggins/vcoincore,GroestlCoin/bitcoin,RHavar/bitcoin,yenliangl/bitcoin,jonasschnelli/bitcoin,pataquets/namecoin-core,Christewart/bitcoin,tjps/bitcoin,jambolo/bitcoin,ericshawlinux/bitcoin,andreaskern/bitcoin,JeremyRubin/bitcoin,prusnak/bitcoin,GroestlCoin/bitcoin,dscotese/bitcoin,cdecker/bitcoin,mruddy/bitcoin,bitcoinknots/bitcoin,bitcoin/bitcoin,kallewoof/bitcoin,litecoin-project/litecoin,fujicoin/fujicoin,AkioNak/bitcoin,thrasher-/litecoin,guncoin/guncoin,GroestlCoin/GroestlCoin,vmp32k/litecoin,untrustbank/litecoin,lateminer/bitcoin,andreaskern/bitcoin,myriadteam/myriadcoin,sstone/bitcoin,tecnovert/particl-core,myriadcoin/myriadcoin,mruddy/bitcoin,GlobalBoost/GlobalBoost,MeshCollider/bitcoin,EthanHeilman/bitcoin,GroestlCoin/GroestlCoin,gjhiggins/vcoincore,Flowdalic/bitcoin,namecoin/namecore,peercoin/peercoin,GlobalBoost/GlobalBoost,instagibbs/bitcoin,cdecker/bitcoin,ajtowns/bitcoin,GlobalBoost/GlobalBoost,dscotese/bitcoin,peercoin/peercoin,midnightmagic/bitcoin,guncoin/guncoin,JeremyRubin/bitcoin,jnewbery/bitcoin,bitcoinsSG/bitcoin,monacoinproject/monacoin,yenliangl/bitcoin,RHavar/bitcoin,Flowdalic/bitcoin,cdecker/bitcoin,namecoin/namecoin-core,fujicoin/fujicoin,GroestlCoin/GroestlCoin,bitcoin/bitcoin,afk11/bitcoin,mruddy/bitcoin,ajtowns/bitcoin,DigitalPandacoin/pandacoin,domob1812/bitcoin,bitcoinknots/bitcoin,digibyte/digibyte,AkioNak/bitcoin,AkioNak/bitcoin,Kogser/bitcoin,litecoin-project/litecoin,kazcw/bitcoin,apoelstra/bitcoin,MarcoFalke/bitcoin,jtimon/bitcoin,rnicoll/dogecoin,lbryio/lbrycrd,Xekyo/bitcoin,Kogser/bitcoin,lbryio/lbrycrd,practicalswift/bitcoin,domob1812/namecore,jlopp/statoshi,ahmedbodi/vertcoin,vmp32k/litecoin,n1bor/bitcoin,jnewbery/bitcoin,andreaskern/bitcoin,mm-s/bitcoin,GroestlCoin/bitcoin,ericshawlinux/bitcoin,vertcoin/vertcoin,r8921039/bitcoin,EthanHeilman/bitcoin,bespike/litecoin,ericshawlinux/bitcoin,Bushstar/UFO-Project,nikkitan/bitcoin,namecoin/namecoin-core,jtimon/bitcoin,OmniLayer/omnicore,Kogser/bitcoin,tjps/bitcoin,r8921039/bitcoin,pstratem/bitcoin,wellenreiter01/Feathercoin,tjps/bitcoin,ahmedbodi/vertcoin,lateminer/bitcoin,nikkitan/bitcoin,tecnovert/particl-core,ahmedbodi/vertcoin,Flowdalic/bitcoin,myriadcoin/myriadcoin,afk11/bitcoin,prusnak/bitcoin,Sjors/bitcoin,lateminer/bitcoin,achow101/bitcoin,particl/particl-core,domob1812/bitcoin,bespike/litecoin,midnightmagic/bitcoin,vmp32k/litecoin,yenliangl/bitcoin,monacoinproject/monacoin,jambolo/bitcoin,jlopp/statoshi,Kogser/bitcoin,digibyte/digibyte,prusnak/bitcoin,achow101/bitcoin,tecnovert/particl-core,myriadteam/myriadcoin,r8921039/bitcoin,JeremyRubin/bitcoin,CryptArc/bitcoin,jamesob/bitcoin,kallewoof/bitcoin,monacoinproject/monacoin,mitchellcash/bitcoin,apoelstra/bitcoin,mm-s/bitcoin,fanquake/bitcoin,afk11/bitcoin,AkioNak/bitcoin,untrustbank/litecoin,DigitalPandacoin/pandacoin,ahmedbodi/vertcoin,MarcoFalke/bitcoin,myriadcoin/myriadcoin,dscotese/bitcoin,CryptArc/bitcoin,jonasschnelli/bitcoin,GroestlCoin/bitcoin,kazcw/bitcoin,particl/particl-core,namecoin/namecoin-core,jamesob/bitcoin,jamesob/bitcoin,gjhiggins/vcoincore,apoelstra/bitcoin,fujicoin/fujicoin,MeshCollider/bitcoin,GlobalBoost/GlobalBoost,RHavar/bitcoin,tecnovert/particl-core,Kogser/bitcoin,untrustbank/litecoin,midnightmagic/bitcoin,pataquets/namecoin-core,myriadcoin/myriadcoin,prusnak/bitcoin,bespike/litecoin,nikkitan/bitcoin,alecalve/bitcoin,alecalve/bitcoin,achow101/bitcoin,kallewoof/bitcoin,fujicoin/fujicoin,myriadcoin/myriadcoin,DigitalPandacoin/pandacoin,apoelstra/bitcoin,fujicoin/fujicoin,rnicoll/bitcoin,r8921039/bitcoin,litecoin-project/litecoin,OmniLayer/omnicore,lbryio/lbrycrd,Xekyo/bitcoin,vertcoin/vertcoin,ajtowns/bitcoin,ericshawlinux/bitcoin,namecoin/namecoin-core,bitcoin/bitcoin,domob1812/namecore,MarcoFalke/bitcoin,rnicoll/dogecoin,peercoin/peercoin,namecoin/namecore,droark/bitcoin,CryptArc/bitcoin,bitcoinsSG/bitcoin,cdecker/bitcoin,apoelstra/bitcoin,domob1812/bitcoin,pstratem/bitcoin,Bushstar/UFO-Project,digibyte/digibyte,instagibbs/bitcoin,midnightmagic/bitcoin,mruddy/bitcoin,afk11/bitcoin,MarcoFalke/bitcoin,rnicoll/dogecoin,anditto/bitcoin,gjhiggins/vcoincore,jnewbery/bitcoin,sstone/bitcoin,apoelstra/bitcoin,rnicoll/bitcoin,Xekyo/bitcoin,ahmedbodi/vertcoin,alecalve/bitcoin,n1bor/bitcoin,domob1812/bitcoin,particl/particl-core,qtumproject/qtum,droark/bitcoin,mm-s/bitcoin,jamesob/bitcoin,guncoin/guncoin,BTCGPU/BTCGPU,jnewbery/bitcoin,ericshawlinux/bitcoin,wellenreiter01/Feathercoin,Sjors/bitcoin,bitcoinsSG/bitcoin,fanquake/bitcoin,wellenreiter01/Feathercoin,GroestlCoin/bitcoin,OmniLayer/omnicore,Xekyo/bitcoin,Sjors/bitcoin,MeshCollider/bitcoin,thrasher-/litecoin,particl/particl-core,dscotese/bitcoin,namecoin/namecoin-core,BTCGPU/BTCGPU,Kogser/bitcoin,AkioNak/bitcoin,mruddy/bitcoin,vmp32k/litecoin,RHavar/bitcoin,guncoin/guncoin,alecalve/bitcoin,mitchellcash/bitcoin,rnicoll/bitcoin,h4x3rotab/BTCGPU,namecoin/namecoin-core,GroestlCoin/GroestlCoin,pstratem/bitcoin,peercoin/peercoin,sipsorcery/bitcoin,peercoin/peercoin,mm-s/bitcoin,afk11/bitcoin,Christewart/bitcoin,JeremyRubin/bitcoin,mitchellcash/bitcoin,digibyte/digibyte,BTCGPU/BTCGPU,practicalswift/bitcoin,vertcoin/vertcoin,MarcoFalke/bitcoin,mitchellcash/bitcoin,wellenreiter01/Feathercoin,instagibbs/bitcoin