| @@ -234,11 +234,8 @@ class TimeOut(Attribute): | |||||
| @_tbprinter | @_tbprinter | ||||
| async def timeout_coro(self): | async def timeout_coro(self): | ||||
| print('tc1') | |||||
| async with self._brd.lock: | async with self._brd.lock: | ||||
| print('tc2') | |||||
| await self._brd.release() | await self._brd.release() | ||||
| print('tc3') | |||||
| def timeout_callback(self): | def timeout_callback(self): | ||||
| self._task = asyncio.create_task(self.timeout_coro()) | self._task = asyncio.create_task(self.timeout_coro()) | ||||
| @@ -276,6 +273,13 @@ class SerialConsole(DefROAttribute): | |||||
| raise RuntimeError('activate failed: %d' % ret) | raise RuntimeError('activate failed: %d' % ret) | ||||
| class BoardImpl: | class BoardImpl: | ||||
| ''' | |||||
| This implements the interface for a board. The lock, inst.lock, | |||||
| needs to be locked before most method calls. This is to ensure | |||||
| that the board is in a stable state, such as the jail will not | |||||
| be destroyed before the operation completes. | |||||
| ''' | |||||
| def __init__(self, name, brdclass, options): | def __init__(self, name, brdclass, options): | ||||
| self.name = name | self.name = name | ||||
| self.brdclass = brdclass | self.brdclass = brdclass | ||||
| @@ -1641,7 +1645,6 @@ class TestAttrs(unittest.IsolatedAsyncioTestCase): | |||||
| # that the expiration is no longer there | # that the expiration is no longer there | ||||
| self.assertIsNone(to._exp) | self.assertIsNone(to._exp) | ||||
| print('z') | |||||
| # and the timeout passes | # and the timeout passes | ||||
| evt = asyncio.Event() | evt = asyncio.Event() | ||||
| @@ -1649,33 +1652,26 @@ class TestAttrs(unittest.IsolatedAsyncioTestCase): | |||||
| loop.call_at(exp + epsilon, evt.set) | loop.call_at(exp + epsilon, evt.set) | ||||
| await evt.wait() | await evt.wait() | ||||
| print('a') | |||||
| # that when reserved/activated | # that when reserved/activated | ||||
| async with brd.lock: | async with brd.lock: | ||||
| await brd.reserve() | await brd.reserve() | ||||
| await brd.activate() | await brd.activate() | ||||
| print('b') | |||||
| # but the board is locked for some reason | # but the board is locked for some reason | ||||
| await brd.lock.acquire() | await brd.lock.acquire() | ||||
| print('c') | |||||
| # and the callback is called | # and the callback is called | ||||
| await asyncio.sleep(.02) | await asyncio.sleep(.02) | ||||
| print('d') | |||||
| # that the task has been scheduled | # that the task has been scheduled | ||||
| self.assertIsNotNone(to._task) | self.assertIsNotNone(to._task) | ||||
| print('e') | |||||
| # that it can be deactivated | # that it can be deactivated | ||||
| await brd.deactivate() | await brd.deactivate() | ||||
| print('f') | |||||
| # and when the board lock is released | # and when the board lock is released | ||||
| brd.lock.release() | brd.lock.release() | ||||
| print('g') | |||||
| # that the board was not released | # that the board was not released | ||||
| self.assertTrue(brd.reserved) | self.assertTrue(brd.reserved) | ||||