Skip to content

Commit

Permalink
fix lock release bug, add visual indicator of activity, add version t…
Browse files Browse the repository at this point in the history
…o ui #14 #16
  • Loading branch information
3ll3d00d committed Jan 23, 2021
1 parent 5eaa385 commit 70594ee
Show file tree
Hide file tree
Showing 12 changed files with 498 additions and 335 deletions.
22 changes: 13 additions & 9 deletions ezbeq/minidsp.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from contextlib import contextmanager

import time
import json
import logging
import os
import time
from contextlib import contextmanager
from typing import List, Optional

from flask import request
Expand Down Expand Up @@ -46,7 +45,8 @@ def clear(self, slot: int):
self.__update(slot, 'Empty')

def get(self):
return {'slots': self.__state, 'active': self.__active_slot}
return [{**s, 'active': True if self.__active_slot is not None and s['id'] == self.__active_slot else False}
for s in self.__state]


class Minidsps(Resource):
Expand Down Expand Up @@ -207,12 +207,16 @@ def to_millis(start, end, precision=1):

@contextmanager
def acquire_timeout(lock, timeout):
logger.debug("Acquiring LOCK")
logger.info("Acquiring LOCK")
result = lock.acquire(timeout=timeout)
yield result
if result:
logger.debug("Releasing LOCK")
lock.release()
try:
yield result
finally:
if result:
logger.info("Releasing LOCK")
lock.release()
else:
logger.info("No LOCK to release")


@contextmanager
Expand Down

0 comments on commit 70594ee

Please sign in to comment.