Browse Source

forgot to remove debug prints, add comment about BoardImpl lock..

main
John-Mark Gurney 3 years ago
parent
commit
338c33a62b
1 changed files with 7 additions and 11 deletions
  1. +7
    -11
      bitelab/__init__.py

+ 7
- 11
bitelab/__init__.py View File

@@ -234,11 +234,8 @@ class TimeOut(Attribute):

@_tbprinter
async def timeout_coro(self):
print('tc1')
async with self._brd.lock:
print('tc2')
await self._brd.release()
print('tc3')

def timeout_callback(self):
self._task = asyncio.create_task(self.timeout_coro())
@@ -276,6 +273,13 @@ class SerialConsole(DefROAttribute):
raise RuntimeError('activate failed: %d' % ret)

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):
self.name = name
self.brdclass = brdclass
@@ -1641,7 +1645,6 @@ class TestAttrs(unittest.IsolatedAsyncioTestCase):

# that the expiration is no longer there
self.assertIsNone(to._exp)
print('z')

# and the timeout passes
evt = asyncio.Event()
@@ -1649,33 +1652,26 @@ class TestAttrs(unittest.IsolatedAsyncioTestCase):
loop.call_at(exp + epsilon, evt.set)
await evt.wait()

print('a')
# that when reserved/activated
async with brd.lock:
await brd.reserve()
await brd.activate()

print('b')
# but the board is locked for some reason
await brd.lock.acquire()

print('c')
# and the callback is called
await asyncio.sleep(.02)

print('d')
# that the task has been scheduled
self.assertIsNotNone(to._task)

print('e')
# that it can be deactivated
await brd.deactivate()

print('f')
# and when the board lock is released
brd.lock.release()

print('g')
# that the board was not released
self.assertTrue(brd.reserved)


Loading…
Cancel
Save