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


Python FCNTL.F_SETFL屬性代碼示例

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


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

示例1: start

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import F_SETFL [as 別名]
def start(self):
        rfd, wfd = self.pipe

        # The read side of the pipe is set to non-blocking I/O; it is
        # 'owned' by medusa.

        flags = fcntl.fcntl(rfd, F_GETFL, 0)
        fcntl.fcntl(rfd, F_SETFL, flags | O_NDELAY)

        # The write side of the pipe is left in blocking mode; it is
        # 'owned' by the thread.  However, we wrap it up as a file object.
        # [who wants to 'write()' to a number?]

        of = os.fdopen(wfd, 'w')

        thread.start_new_thread(
            self.function,
            # put the output file in front of the other arguments
            (of,) + self.args
        ) 
開發者ID:zopefoundation,項目名稱:ZServer,代碼行數:22,代碼來源:thread_channel.py

示例2: makeNonBlocking

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import F_SETFL [as 別名]
def makeNonBlocking(fd):
    fl = fcntl.fcntl(fd, FCNTL.F_GETFL)
    try:
	fcntl.fcntl(fd, FCNTL.F_SETFL, fl | FCNTL.O_NDELAY)
    except AttributeError:
	fcntl.fcntl(fd, FCNTL.F_SETFL, fl | FCNTL.FNDELAY) 
開發者ID:ActiveState,項目名稱:code,代碼行數:8,代碼來源:recipe-52296.py

示例3: setNonBlocking

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import F_SETFL [as 別名]
def setNonBlocking(fd):
    """Make a fd non-blocking."""
    flags = fcntl.fcntl(fd, FCNTL.F_GETFL)
    flags = flags | os.O_NONBLOCK
    fcntl.fcntl(fd, FCNTL.F_SETFL, flags) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:7,代碼來源:fdesc.py

示例4: setBlocking

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import F_SETFL [as 別名]
def setBlocking(fd):
    """Make a fd blocking."""
    flags = fcntl.fcntl(fd, FCNTL.F_GETFL)
    flags = flags & ~os.O_NONBLOCK
    fcntl.fcntl(fd, FCNTL.F_SETFL, flags) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:7,代碼來源:fdesc.py

示例5: open

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import F_SETFL [as 別名]
def open(self):
        """Open port with current settings. This may throw a SerialException
           if the port cannot be opened."""
        if self._port is None:
            raise SerialException("Port must be configured before it can be used.")
        if self._isOpen:
            raise SerialException("Port is already open.")
        self.fd = None
        # open
        try:
            self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
        except IOError, msg:
            self.fd = None
            raise SerialException(msg.errno, "could not open port %s: %s" % (self._port, msg))
        #~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0)  # set blocking

        try:
            self._reconfigurePort()
        except:
            try:
                os.close(self.fd)
            except:
                # ignore any exception when closing the port
                # also to keep original exception that happened when setting up
                pass
            self.fd = None
            raise
        else:
            self._isOpen = True
        self.flushInput() 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:32,代碼來源:serialposix.py

示例6: nonblocking

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import F_SETFL [as 別名]
def nonblocking(self):
        """internal - not portable!"""
        if not self._isOpen: raise portNotOpenError
        fcntl.fcntl(self.fd, FCNTL.F_SETFL, os.O_NONBLOCK) 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:6,代碼來源:serialposix.py

示例7: open

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import F_SETFL [as 別名]
def open(self):
        """\
        Open port with current settings. This may throw a SerialException
        if the port cannot be opened."""
        if self._port is None:
            raise SerialException("Port must be configured before it can be used.")
        if self._isOpen:
            raise SerialException("Port is already open.")
        self.fd = None
        # open
        try:
            self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
        except OSError, msg:
            self.fd = None
            raise SerialException(msg.errno, "could not open port %s: %s" % (self._port, msg))
        #~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0)  # set blocking

        try:
            self._reconfigurePort()
        except:
            try:
                os.close(self.fd)
            except:
                # ignore any exception when closing the port
                # also to keep original exception that happened when setting up
                pass
            self.fd = None
            raise
        else:
            self._isOpen = True
        self.flushInput() 
開發者ID:nortd,項目名稱:driveboardapp,代碼行數:33,代碼來源:serialposix.py

示例8: open

# 需要導入模塊: import FCNTL [as 別名]
# 或者: from FCNTL import F_SETFL [as 別名]
def open(self):
        """Open port with current settings. This may throw a SerialException
           if the port cannot be opened."""
        if self._port is None:
            raise SerialException("Port must be configured before it can be used.")
        if self._isOpen:
            raise SerialException("Port is already open.")
        self.fd = None
        # open
        try:
            self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
        except Exception, msg:
            self.fd = None
            raise SerialException("could not open port %s: %s" % (self._port, msg))
        #~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0)  # set blocking

        try:
            self._reconfigurePort()
        except:
            try:
                os.close(self.fd)
            except:
                # ignore any exception when closing the port
                # also to keep original exception that happened when setting up
                pass
            self.fd = None
            raise
        else:
            self._isOpen = True
        #~ self.flushInput() 
開發者ID:respeaker,項目名稱:get_started_with_respeaker,代碼行數:32,代碼來源:serialposix.py


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