Ticket #5052: fallback.diff

File fallback.diff, 2.4 KB (added by soyt, 6 years ago)
  • twisted/internet/test/test_process.py

     
    792792    def test_inaccurateDevFDResults(self):
    793793        """
    794794        If there is no proc filesystem and /dev/fd returns inaccurate
    795         information, L{_process._fallbackFDImplementation} is selected.  This is
     795        information, one of L{_process._resourceFDImplementation} or
     796        L{_process._fallbackFDImplementation} is selected.  This is
    796797        like FreeBSD without I{fdescfs} mounted.
    797798        """
    798799        self.procfs = False
    799800        self.devfs = True
    800801        self.accurateDevFDResults = False
    801         self.assertEquals(
     802        self.assertIn(
    802803            self.detector._getImplementation().func_name,
    803             '_fallbackFDImplementation')
     804            ('_fallbackFDImplementation', '_resourceFDImplementation'))
    804805
    805806
    806807    def test_procFilesystem(self):
  • twisted/internet/process.py

     
    502502        /proc/%d/fd exists, if so use that.
    503503       
    504504        Otherwise, ask resource.getrlimit, if that throws an exception, then
    505         fallback to _fallbackFDImplementation.
     505        fallback to either _resourceFDImplementation if the resource module works
     506        or _fallbackFDImplementation as last resort.
    506507        """
    507508        try:
    508509            self.listdir("/dev/fd")
    509510            if self._checkDevFDSanity(): # FreeBSD support :-)
    510511                return self._devFDImplementation
    511             else:
    512                 return self._fallbackFDImplementation
    513512        except:
    514513            try:
    515514                self.listdir("/proc/%d/fd" % (self.getpid(),))
    516515                return self._procFDImplementation
    517516            except:
    518                 try:
    519                     self._resourceFDImplementation() # Imports resource
    520                     return self._resourceFDImplementation
    521                 except:
    522                     return self._fallbackFDImplementation
     517                pass
    523518
     519        try:
     520            self._resourceFDImplementation() # Imports resource
     521            return self._resourceFDImplementation
     522        except:
     523            return self._fallbackFDImplementation
    524524
    525525    def _checkDevFDSanity(self):
    526526        """