本文整理汇总了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
)
示例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)
示例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)
示例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)
示例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()
示例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)
示例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()
示例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()