mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
tests: Pull OutputChecker fixes
Mark the thread as daemon. Also use poll and fix a wrong variable reference.
This commit is contained in:
committed by
Benjamin Berg
parent
8c0876ae49
commit
f4995dcabe
@ -43,16 +43,18 @@ class OutputChecker(object):
|
|||||||
fcntl.fcntl(self._pipe_fd_w, fcntl.F_GETFL) | os.O_CLOEXEC)
|
fcntl.fcntl(self._pipe_fd_w, fcntl.F_GETFL) | os.O_CLOEXEC)
|
||||||
|
|
||||||
# Start copier thread
|
# Start copier thread
|
||||||
self._thread = threading.Thread(target=self._copy)
|
self._thread = threading.Thread(target=self._copy, daemon=True)
|
||||||
self._thread.start()
|
self._thread.start()
|
||||||
|
|
||||||
def _copy(self):
|
def _copy(self):
|
||||||
|
p = select.poll()
|
||||||
|
p.register(self._pipe_fd_r)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
# Be lazy and wake up occasionally in case _pipe_fd_r became invalid
|
# Be lazy and wake up occasionally in case _pipe_fd_r became invalid
|
||||||
# The reason to do this is because os.read() will *not* return if the
|
# The reason to do this is because os.read() will *not* return if the
|
||||||
# FD is forcefully closed.
|
# FD is forcefully closed.
|
||||||
select.select([self._pipe_fd_r], [], [], 0.1)
|
p.poll(0.1)
|
||||||
|
|
||||||
r = os.read(self._pipe_fd_r, 1024)
|
r = os.read(self._pipe_fd_r, 1024)
|
||||||
if not r:
|
if not r:
|
||||||
@ -130,7 +132,7 @@ class OutputChecker(object):
|
|||||||
if failmsg:
|
if failmsg:
|
||||||
raise AssertionError(failmsg)
|
raise AssertionError(failmsg)
|
||||||
else:
|
else:
|
||||||
raise AssertionError('Found needle %s but shouldn\'t have been there (timeout: %0.2f)' % (str(needle_re), timeout))
|
raise AssertionError('Found needle %s but shouldn\'t have been there (timeout: %0.2f)' % (str(needle_re), wait))
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user