当前位置: 首页>>代码示例>>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;未经允许,请勿转载。