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


Python asyncore.file_wrapper方法代码示例

本文整理汇总了Python中asyncore.file_wrapper方法的典型用法代码示例。如果您正苦于以下问题:Python asyncore.file_wrapper方法的具体用法?Python asyncore.file_wrapper怎么用?Python asyncore.file_wrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在asyncore的用法示例。


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

示例1: test_recv

# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_wrapper [as 别名]
def test_recv(self):
        fd = os.open(TESTFN, os.O_RDONLY)
        w = asyncore.file_wrapper(fd)
        os.close(fd)

        self.assertNotEqual(w.fd, fd)
        self.assertNotEqual(w.fileno(), fd)
        self.assertEqual(w.recv(13), "It's not dead")
        self.assertEqual(w.read(6), ", it's")
        w.close()
        self.assertRaises(OSError, w.read, 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_asyncore.py

示例2: test_send

# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_wrapper [as 别名]
def test_send(self):
        d1 = "Come again?"
        d2 = "I want to buy some cheese."
        fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND)
        w = asyncore.file_wrapper(fd)
        os.close(fd)

        w.write(d1)
        w.send(d2)
        w.close()
        self.assertEqual(file(TESTFN).read(), self.d + d1 + d2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_asyncore.py

示例3: test_close_twice

# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_wrapper [as 别名]
def test_close_twice(self):
        fd = os.open(TESTFN, os.O_RDONLY)
        f = asyncore.file_wrapper(fd)
        os.close(fd)

        os.close(f.fd)  # file_wrapper dupped fd
        with self.assertRaises(OSError):
            f.close()

        self.assertEqual(f.fd, -1)
        # calling close twice should not fail
        f.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_asyncore.py

示例4: test_recv

# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_wrapper [as 别名]
def test_recv(self):
        fd = os.open(support.TESTFN, os.O_RDONLY)
        w = asyncore.file_wrapper(fd)
        os.close(fd)

        self.assertNotEqual(w.fd, fd)
        self.assertNotEqual(w.fileno(), fd)
        self.assertEqual(w.recv(13), b"It's not dead")
        self.assertEqual(w.read(6), b", it's")
        w.close()
        self.assertRaises(OSError, w.read, 1) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_asyncore.py

示例5: test_send

# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_wrapper [as 别名]
def test_send(self):
        d1 = b"Come again?"
        d2 = b"I want to buy some cheese."
        fd = os.open(support.TESTFN, os.O_WRONLY | os.O_APPEND)
        w = asyncore.file_wrapper(fd)
        os.close(fd)

        w.write(d1)
        w.send(d2)
        w.close()
        with open(support.TESTFN, 'rb') as file:
            self.assertEqual(file.read(), self.d + d1 + d2) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:14,代码来源:test_asyncore.py

示例6: test_resource_warning

# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_wrapper [as 别名]
def test_resource_warning(self):
        # Issue #11453
        fd = os.open(support.TESTFN, os.O_RDONLY)
        f = asyncore.file_wrapper(fd)

        os.close(fd)
        with support.check_warnings(('', ResourceWarning)):
            f = None
            support.gc_collect() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:test_asyncore.py

示例7: test_close_twice

# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import file_wrapper [as 别名]
def test_close_twice(self):
        fd = os.open(support.TESTFN, os.O_RDONLY)
        f = asyncore.file_wrapper(fd)
        os.close(fd)

        f.close()
        self.assertEqual(f.fd, -1)
        # calling close twice should not fail
        f.close() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:test_asyncore.py


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