当前位置: 首页>>代码示例>>Python>>正文


Python io.RawIOBase类代码示例

本文整理汇总了Python中io.RawIOBase的典型用法代码示例。如果您正苦于以下问题:Python RawIOBase类的具体用法?Python RawIOBase怎么用?Python RawIOBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RawIOBase类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: close

 def close(self):
     if self._sock is None:
         return
     else:
         self._sock.close()
         self._sock = None
         RawIOBase.close(self)
开发者ID:mikeboers,项目名称:Nitrogen,代码行数:7,代码来源:websocket.py

示例2: __init__

    def __init__(self, fileno, mode='r', closefd=True):
        RawIOBase.__init__(self) # Python 2: pylint:disable=no-member,non-parent-init-called

        self._closefd = closefd
        self._fileno = fileno
        make_nonblocking(fileno)
        readable = 'r' in mode
        writable = 'w' in mode

        self.hub = get_hub()
        io_watcher = self.hub.loop.io
        try:
            if readable:
                self._read_event = io_watcher(fileno, 1)

            if writable:
                self._write_event = io_watcher(fileno, 2)
        except:
            # If anything goes wrong, it's important to go ahead and
            # close these watchers *now*, especially under libuv, so
            # that they don't get eventually reclaimed by the garbage
            # collector at some random time, thanks to the C level
            # slot (even though we don't seem to have any actual references
            # at the Python level). Previously, if we didn't close now,
            # that random close in the future would cause issues if we had duplicated
            # the fileno (if a wrapping with statement had closed an open fileobject,
            # for example)

            # test__fileobject can show a failure if this doesn't happen
            # TRAVIS=true GEVENT_LOOP=libuv python -m gevent.tests.test__fileobject \
            #    TestFileObjectPosix.test_seek TestFileObjectThread.test_bufsize_0
            self.close()
            raise
开发者ID:gevent,项目名称:gevent,代码行数:33,代码来源:_fileobjectposix.py

示例3: close

    def close(self):
        """Close open resources."""

        RawIOBase.close(self)

        if self.fd:
            self.fd.close()
            self.fd = None
开发者ID:pleo1,项目名称:nzbstream,代码行数:8,代码来源:rarspec.py

示例4: close

 def close(self):
     """Close the SocketIO object. This doesn't close the underlying
     socket, except if all references to it have disappeared.
     """
     if self.closed:
         return
     RawIOBase.close(self)
     self._sock = None
开发者ID:PeterScott,项目名称:http-parser,代码行数:8,代码来源:reader.py

示例5: wait_until_ready

    def wait_until_ready(self, channel:RawIOBase, timeout=60):
        """
        sends ' ' (space) and waits for the corresponding ACK message. Once we have 3 of these in a row we can be fairly
        certain the device is ready for ymodem.
        :param channel:
        :param timeout:
        :return:
        """
        success_count = 0
        while channel.readline():  # flush any existing data
            success_count = 0

        while success_count < 2:
            channel.write(b' ')
            result = channel.read()
            if result and result[0]==LightYModemProtocol.ack:
                success_count += 1
开发者ID:spark,项目名称:device-updater,代码行数:17,代码来源:ymodem.py

示例6: __init__

    def __init__(self, rf, inf):
        """Fill common fields"""

        RawIOBase.__init__(self)

        # standard io.* properties
        self.name = inf.filename
        self.mode = 'rb'

        self.rf = rf
        self.inf = inf
        self.crc_check = rf._crc_check
        self.fd = None
        self.CRC = 0
        self.remain = 0

        self._open()
开发者ID:pleo1,项目名称:nzbstream,代码行数:17,代码来源:rarspec.py

示例7: __init__

    def __init__(self, fileno, mode='r', closefd=True):
        RawIOBase.__init__(self) # Python 2: pylint:disable=no-member,non-parent-init-called
        self._closed = False
        self._closefd = closefd
        self._fileno = fileno
        make_nonblocking(fileno)
        self._readable = 'r' in mode
        self._writable = 'w' in mode
        self.hub = get_hub()

        io_watcher = self.hub.loop.io
        if self._readable:
            self._read_event = io_watcher(fileno, 1)

        if self._writable:
            self._write_event = io_watcher(fileno, 2)

        self._seekable = None
开发者ID:18965050,项目名称:gevent,代码行数:18,代码来源:_fileobjectposix.py

示例8: __init__

 def __init__(self, fileno, mode='r', closefd=True):
     RawIOBase.__init__(self)
     self._closed = False
     self._closefd = closefd
     self._fileno = fileno
     make_nonblocking(fileno)
     self._readable = 'r' in mode
     self._writable = 'w' in mode
     self.hub = get_hub()
     io = self.hub.loop.io
     if self._readable:
         self._read_event = io(fileno, 1)
     else:
         self._read_event = None
     if self._writable:
         self._write_event = io(fileno, 2)
     else:
         self._write_event = None
开发者ID:Meteorix,项目名称:gevent,代码行数:18,代码来源:_fileobject3.py

示例9: __init__

 def __init__(self, sock):
     RawIOBase.__init__(self)
     self._sock = sock
开发者ID:mikeboers,项目名称:Nitrogen,代码行数:3,代码来源:websocket.py

示例10: __init__

 def __init__(self, *args, **kwargs):
     RawIOBase.__init__(self)
     FtdiSerial.__init__(self, *args, **kwargs)
开发者ID:eblot,项目名称:pyftdi,代码行数:3,代码来源:protocol_ftdi.py

示例11: bulk_copy

def bulk_copy(read_from: io.RawIOBase, write_to: io.RawIOBase):
    while True:
        chunk = read_from.read(BUFFER_SIZE)
        if not chunk:
            break
        write_to.write(chunk)
开发者ID:mruffalo,项目名称:btrfs-sync-daemon,代码行数:6,代码来源:btrfs_incremental_send.py


注:本文中的io.RawIOBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。