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


Python RawIOBase.__init__方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from io import RawIOBase [as 別名]
# 或者: from io.RawIOBase import __init__ [as 別名]
    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,代碼行數:35,代碼來源:_fileobjectposix.py

示例2: __init__

# 需要導入模塊: from io import RawIOBase [as 別名]
# 或者: from io.RawIOBase import __init__ [as 別名]
    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,代碼行數:19,代碼來源:rarspec.py

示例3: __init__

# 需要導入模塊: from io import RawIOBase [as 別名]
# 或者: from io.RawIOBase import __init__ [as 別名]
    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,代碼行數:20,代碼來源:_fileobjectposix.py

示例4: __init__

# 需要導入模塊: from io import RawIOBase [as 別名]
# 或者: from io.RawIOBase import __init__ [as 別名]
 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,代碼行數:20,代碼來源:_fileobject3.py

示例5: __init__

# 需要導入模塊: from io import RawIOBase [as 別名]
# 或者: from io.RawIOBase import __init__ [as 別名]
 def __init__(self, sock):
     RawIOBase.__init__(self)
     self._sock = sock
開發者ID:mikeboers,項目名稱:Nitrogen,代碼行數:5,代碼來源:websocket.py

示例6: __init__

# 需要導入模塊: from io import RawIOBase [as 別名]
# 或者: from io.RawIOBase import __init__ [as 別名]
 def __init__(self, *args, **kwargs):
     RawIOBase.__init__(self)
     FtdiSerial.__init__(self, *args, **kwargs)
開發者ID:eblot,項目名稱:pyftdi,代碼行數:5,代碼來源:protocol_ftdi.py


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