Merge "Python 3.7: fix os.errno -> errno" into stable/rocky
This commit is contained in:
commit
e89450c44e
|
@ -20,6 +20,10 @@
|
|||
# http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
|
||||
|
||||
|
||||
try:
|
||||
import errno
|
||||
except ImportError:
|
||||
import os.errno as errno
|
||||
import fcntl
|
||||
import os
|
||||
import time
|
||||
|
@ -206,7 +210,7 @@ def _exclusive_write_or_pass(path, buf):
|
|||
f.flush()
|
||||
return True
|
||||
except IOError as e:
|
||||
if e.errno == os.errno.EWOULDBLOCK:
|
||||
if e.errno == errno.EWOULDBLOCK:
|
||||
LOG.debug('%s locked; will try again (later)', path)
|
||||
attempts -= 1
|
||||
time.sleep(_EXCLUSIVE_WRITE_ATTEMPTS_DELAY)
|
||||
|
@ -261,7 +265,7 @@ def _configure_unknown_hosts():
|
|||
if os.stat(path).st_size == len(wildcard_filter):
|
||||
return
|
||||
except OSError as e:
|
||||
if e.errno != os.errno.ENOENT:
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
|
||||
if _exclusive_write_or_pass(path, '%s' % wildcard_filter):
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
try:
|
||||
import errno
|
||||
except ImportError:
|
||||
import os.errno as errno
|
||||
import datetime
|
||||
import os
|
||||
|
||||
|
@ -131,7 +135,7 @@ class TestExclusiveWriteOrPass(test_base.BaseTest):
|
|||
|
||||
def test_write_would_block(self):
|
||||
err = IOError('Oops!')
|
||||
err.errno = os.errno.EWOULDBLOCK
|
||||
err.errno = errno.EWOULDBLOCK
|
||||
# lock/unlock paired calls
|
||||
self.mock_fcntl.side_effect = [
|
||||
# first try
|
||||
|
@ -156,7 +160,7 @@ class TestExclusiveWriteOrPass(test_base.BaseTest):
|
|||
'ironic_inspector.pxe_filter.dnsmasq._EXCLUSIVE_WRITE_ATTEMPTS',
|
||||
1))
|
||||
err = IOError('Oops!')
|
||||
err.errno = os.errno.EWOULDBLOCK
|
||||
err.errno = errno.EWOULDBLOCK
|
||||
self.mock_fcntl.side_effect = [err, None]
|
||||
|
||||
wrote = dnsmasq._exclusive_write_or_pass(self.path, self.buf)
|
||||
|
@ -180,7 +184,7 @@ class TestExclusiveWriteOrPass(test_base.BaseTest):
|
|||
def test_write_custom_ioerror(self):
|
||||
|
||||
err = IOError('Oops!')
|
||||
err.errno = os.errno.EBADF
|
||||
err.errno = errno.EBADF
|
||||
self.mock_fcntl.side_effect = [err, None]
|
||||
|
||||
self.assertRaisesRegex(
|
||||
|
|
Loading…
Reference in New Issue