(self)
| 126 | @requires_subprocess() |
| 127 | @requires_resource('walltime') |
| 128 | def test_poll2(self): |
| 129 | cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' |
| 130 | proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, |
| 131 | bufsize=0) |
| 132 | self.enterContext(proc) |
| 133 | p = proc.stdout |
| 134 | pollster = select.poll() |
| 135 | pollster.register( p, select.POLLIN ) |
| 136 | for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10: |
| 137 | fdlist = pollster.poll(tout) |
| 138 | if (fdlist == []): |
| 139 | continue |
| 140 | fd, flags = fdlist[0] |
| 141 | if flags & select.POLLHUP: |
| 142 | line = p.readline() |
| 143 | if line != b"": |
| 144 | self.fail('error: pipe seems to be closed, but still returns data') |
| 145 | continue |
| 146 | |
| 147 | elif flags & select.POLLIN: |
| 148 | line = p.readline() |
| 149 | if not line: |
| 150 | break |
| 151 | self.assertEqual(line, b'testing...\n') |
| 152 | continue |
| 153 | else: |
| 154 | self.fail('Unexpected return value from select.poll: %s' % fdlist) |
| 155 | |
| 156 | def test_poll3(self): |
| 157 | # test int overflow |
nothing calls this directly
no test coverage detected