當前位置: 首頁>>代碼示例>>Python>>正文


Python errno.EBUSY屬性代碼示例

本文整理匯總了Python中errno.EBUSY屬性的典型用法代碼示例。如果您正苦於以下問題:Python errno.EBUSY屬性的具體用法?Python errno.EBUSY怎麽用?Python errno.EBUSY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在errno的用法示例。


在下文中一共展示了errno.EBUSY屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sendfile_wrapper

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def sendfile_wrapper(self, sock, file, offset, nbytes, headers=[], trailers=[]):
        """A higher level wrapper representing how an application is
        supposed to use sendfile().
        """
        while 1:
            try:
                if self.SUPPORT_HEADERS_TRAILERS:
                    return os.sendfile(sock, file, offset, nbytes, headers,
                                       trailers)
                else:
                    return os.sendfile(sock, file, offset, nbytes)
            except OSError as err:
                if err.errno == errno.ECONNRESET:
                    # disconnected
                    raise
                elif err.errno in (errno.EAGAIN, errno.EBUSY):
                    # we have to retry send data
                    continue
                else:
                    raise 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:22,代碼來源:test_os.py

示例2: test_scrub_inactive_pastes_error

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def test_scrub_inactive_pastes_error(self):
        pastes = [util.testing.PasteFactory.generate(expiry_time=None) for _ in range(15)]
        [util.testing.AttachmentFactory.generate(paste_id=paste.paste_id, file_name='file') for paste in pastes]
        [database.paste.deactivate_paste(paste.paste_id) for paste in pastes[:10]]

        with mock.patch.object(shutil, 'rmtree') as mock_rmtree:
            mock_rmtree.side_effect = OSError(errno.EBUSY)

            self.assertRaises(
                OSError,
                database.paste.scrub_inactive_pastes,
            )

        with mock.patch.object(shutil, 'rmtree') as mock_rmtree:
            mock_rmtree.side_effect = OSError(errno.ENOENT)

            for paste in pastes:
                self.assertIsNotNone(database.paste.get_paste_by_id(paste.paste_id)) 
開發者ID:LINKIWI,項目名稱:modern-paste,代碼行數:20,代碼來源:test_paste.py

示例3: loop_create_device

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def loop_create_device(ctl, fd, offset=None, sizelimit=None):
    while True:
        lo = loop.Loop(ctl.get_unbound())
        try:
            lo.set_fd(fd)
        except OSError as e:
            lo.close()
            if e.errno == errno.EBUSY:
                continue
            raise e
        try:
            lo.set_status(offset=offset, sizelimit=sizelimit, autoclear=True)
        except BlockingIOError:
            lo.clear_fd()
            lo.close()
            continue
        break
    try:
        yield lo
    finally:
        lo.close() 
開發者ID:osbuild,項目名稱:osbuild,代碼行數:23,代碼來源:test_assemblers.py

示例4: play_sound_file

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def play_sound_file(path):
    fp = open(path, 'r')
    size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
    data = fp.read()
    fp.close()

    if enc != SND_FORMAT_MULAW_8:
        print "Expect .au file with 8-bit mu-law samples"
        return

    try:
        a = linuxaudiodev.open('w')
    except linuxaudiodev.error, msg:
        if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
            raise TestSkipped, msg
        raise TestFailed, msg

    # convert the data to 16-bit signed 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:20,代碼來源:test_linuxaudiodev.py

示例5: add_pids

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def add_pids(self, pids, mongroup_name):
        """Adds the pids to the resctrl group and creates mongroup with the pids.
           If the resctrl group does not exists creates it (lazy creation).
           If the mongroup exists adds pids to the group (no error will be thrown)."""
        assert mongroup_name is not None and len(mongroup_name) > 0, 'mongroup_name cannot be empty'

        if self.name != RESCTRL_ROOT_NAME:
            log.debug('creating resctrl group %r', self.name)
            self._create_controlgroup_directory()

        # CTRL GROUP
        # add pids to /tasks file
        log.debug('add_pids: %d pids to %r', len(pids), os.path.join(self.fullpath, 'tasks'))
        self._add_pids_to_tasks_file(pids, os.path.join(self.fullpath, 'tasks'))

        # MON GROUP
        # create mongroup ...
        mongroup_fullpath = self._get_mongroup_fullpath(mongroup_name)
        try:
            log.log(logger.TRACE, 'resctrl: makedirs(%s)', mongroup_fullpath)
            os.makedirs(mongroup_fullpath, exist_ok=True)
        except OSError as e:
            if e.errno == errno.ENOSPC:  # "No space left on device"
                raise Exception("Limit of workloads reached! (Out of available CLoSes/RMIDs!)")
            if e.errno == errno.EBUSY:  # "Device or resource busy"
                raise Exception("Out of RMIDs! Too many RMIDs used or in "
                                "limbo. If you encountered this problem it "
                                "is probably related to one of known issues "
                                "mentioned in Skylake processor's errata."
                                "You could try to increase max "
                                "threshold occupancy in /sys/fs/resctrl"
                                "/info/L3_MON/max_threshold_occupancy file.")
            raise
        # ... and write the pids to the mongroup
        log.debug('add_pids: %d pids to %r', len(pids), os.path.join(mongroup_fullpath, 'tasks'))
        self._add_pids_to_tasks_file(pids, os.path.join(mongroup_fullpath, 'tasks')) 
開發者ID:intel,項目名稱:workload-collocation-agent,代碼行數:38,代碼來源:resctrl.py

示例6: load

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def load(volpath):
    """
    Load and return dictionary from the sidecar
    """
    vol_type = get_vol_type(volpath)
    if not vol_type:
        logging.warning("KV delete - could not determine type of volume %s", volpath)
        return None
    if vol_type == c_uint32(KV_VOL_VIRTUAL).value:
        meta_file = lib.DiskLib_SidecarMakeFileName(volpath.encode(),
                                                    DVOL_KEY.encode())
    else:
        meta_file = get_kv_filename(volpath)
        if not meta_file:
            return None
    retry_count = 0
    vol_name = vmdk_utils.get_volname_from_vmdk_path(volpath)
    while True:
        try:
            with open(meta_file, "r") as fh:
                kv_str = fh.read()
            break
        except IOError as open_error:
            # This is a workaround to the timing/locking with metadata files issue #626
            if open_error.errno == errno.EBUSY and retry_count <= vmdk_utils.VMDK_RETRY_COUNT:
                logging.warning("Meta file %s busy for load(), retrying...", meta_file)
                vmdk_utils.log_volume_lsof(vol_name)
                retry_count += 1
                time.sleep(vmdk_utils.VMDK_RETRY_SLEEP)
            else:
                logging.exception("Failed to access %s", meta_file)
                return None

    try:
        return json.loads(kv_str)
    except ValueError:
        logging.exception("load:Failed to decode meta-data for %s", volpath)
        return None 
開發者ID:vmware-archive,項目名稱:vsphere-storage-for-docker,代碼行數:40,代碼來源:kvESX.py

示例7: play_sound_file

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def play_sound_file(self, data, rate, ssize, nchannels):
        try:
            dsp = ossaudiodev.open('w')
        except IOError, msg:
            if msg.args[0] in (errno.EACCES, errno.ENOENT,
                               errno.ENODEV, errno.EBUSY):
                raise unittest.SkipTest(msg)
            raise

        # at least check that these methods can be invoked 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:test_ossaudiodev.py

示例8: test_main

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def test_main():
    try:
        dsp = ossaudiodev.open('w')
    except (ossaudiodev.error, IOError), msg:
        if msg.args[0] in (errno.EACCES, errno.ENOENT,
                           errno.ENODEV, errno.EBUSY):
            raise unittest.SkipTest(msg)
        raise 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_ossaudiodev.py

示例9: test_main

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def test_main():
    try:
        dsp = linuxaudiodev.open('w')
    except linuxaudiodev.error, msg:
        if msg.args[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
            raise unittest.SkipTest(msg)
        raise 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_linuxaudiodev.py

示例10: test_init_fail_open

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def test_init_fail_open(self, usb_context):
        device = self.Device(0x1000, 0x2000, 1, 2, [
            self.Settings([
                self.Endpoint(0x0004, 0x0002),
                self.Endpoint(0x0084, 0x0002),
            ])
        ])
        device.open = MagicMock()
        device.open.side_effect = [
            nfc.clf.transport.libusb.USBErrorAccess,
            nfc.clf.transport.libusb.USBErrorBusy,
            nfc.clf.transport.libusb.USBErrorNoDevice,
        ]
        usb_context.return_value.getDeviceList.return_value = [device]

        with pytest.raises(IOError) as excinfo:
            nfc.clf.transport.USB(1, 2)
        assert excinfo.value.errno == errno.EACCES

        with pytest.raises(IOError) as excinfo:
            nfc.clf.transport.USB(1, 2)
        assert excinfo.value.errno == errno.EBUSY

        with pytest.raises(IOError) as excinfo:
            nfc.clf.transport.USB(1, 2)
        assert excinfo.value.errno == errno.ENODEV 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:28,代碼來源:test_clf_transport.py

示例11: test_bad_acquire

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def test_bad_acquire(self):
        lock_file = os.path.join(self.lock_dir, 'lock')
        lock = BrokenLock(lock_file, errno.EBUSY)
        self.assertRaises(threading.ThreadError, lock.acquire) 
開發者ID:harlowja,項目名稱:fasteners,代碼行數:6,代碼來源:test_process_lock.py

示例12: initiate_sendfile

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def initiate_sendfile(self):
        """A wrapper around sendfile."""
        try:
            sent = sendfile(self._fileno, self._filefd, self._offset,
                            self.ac_out_buffer_size)
        except OSError as err:
            if err.errno in _ERRNOS_RETRY or err.errno == errno.EBUSY:
                return
            elif err.errno in _ERRNOS_DISCONNECTED:
                self.handle_close()
            else:
                if self.tot_bytes_sent == 0:
                    logger.warning(
                        "sendfile() failed; falling back on using plain send")
                    raise _GiveUpOnSendfile
                else:
                    raise
        else:
            if sent == 0:
                # this signals the channel that the transfer is completed
                self.discard_buffers()
                self.handle_close()
            else:
                self._offset += sent
                self.tot_bytes_sent += sent

    # --- utility methods 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:29,代碼來源:handlers.py

示例13: connect_miniterm

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def connect_miniterm(port):
    try:
        ser = Serial(port, BAUDRATE, parity=PARITY, rtscts=False, xonxoff=False)
        return Miniterm(ser, echo=False)
    except SerialException as e:
        if e.errno == errno.ENOENT:
            sys.stderr.write(
                "Device %r not found. Check your "
                "MicroPython device path settings.\n" % port)
        elif e.errno == errno.EBUSY:
            # Device is busy. Explain what to do.
            sys.stderr.write(
                "Found the device, but it is busy. "
                "Wait up to 20 seconds, or "
                "press the reset button on the "
                "back of the device next to the yellow light; "
                "then try again.\n"
            )
        elif e.errno == errno.EACCES:
            sys.stderr.write("Found the device, but could not connect.\n".format(port))
            sys.stderr.write('%s\n' % (str(e),))
            sys.stderr.write('On linux, try adding yourself to the "dialout" group:\n')
            sys.stderr.write('sudo usermod -a -G dialout <your-username>\n')
        else:
            # Try to be as helpful as possible.
            sys.stderr.write("Found the device, but could not connect via" +
                             " port %r: %s\n" % (port, e))
            sys.stderr.write("I'm not sure what to suggest. :-(\n")
        input("Press ENTER to continue")
        sys.exit(1) 
開發者ID:vlasovskikh,項目名稱:intellij-micropython,代碼行數:32,代碼來源:microrepl.py

示例14: dup2

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def dup2(a, b, timeout=3):
    """Like os.dup2, but retry on EBUSY"""
    dup_err = None
    # give FDs 3 seconds to not be busy anymore
    for i in range(int(10 * timeout)):
        try:
            return os.dup2(a, b)
        except OSError as e:
            dup_err = e
            if e.errno == errno.EBUSY:
                time.sleep(0.1)
            else:
                raise
    if dup_err:
        raise dup_err 
開發者ID:minrk,項目名稱:wurlitzer,代碼行數:17,代碼來源:wurlitzer.py

示例15: lzc_destroy_snaps_translate_errors

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EBUSY [as 別名]
def lzc_destroy_snaps_translate_errors(ret, errlist, snaps, defer):
    if ret == 0:
        return

    def _map(ret, name):
        if ret == errno.EEXIST:
            return lzc_exc.SnapshotIsCloned(name)
        if ret == errno.ENOENT:
            return lzc_exc.PoolNotFound(name)
        if ret == errno.EBUSY:
            return lzc_exc.SnapshotIsHeld(name)
        return _generic_exception(ret, name, "Failed to destroy snapshot")

    _handle_err_list(ret, errlist, snaps, lzc_exc.SnapshotDestructionFailure, _map) 
開發者ID:ClusterHQ,項目名稱:pyzfs,代碼行數:16,代碼來源:_error_translation.py


注:本文中的errno.EBUSY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。