mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 16:23:46 +08:00
Params refactor, simplified (#2300)
* always c++ * Create C++ params class * get works * tests hang now * passes tests * cleanup string formatting * handle interrupt in blocking read * fix memory leak * remove unused constructor * Use delete_db_value directly * Rename put -> write_db_value * filename cleanup * no semicolons in cython * Update common/SConscript Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * add std::string version of delete_db_value * This is handled * cleanup encoding * Add clear method to clear all * add persistent params * fix android build * Should be called clear_all * only import params when needed * set params path on manager import * recusrively create directories * Fix function order * cleanup mkdirp Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: 2e182e5c574ea1468678b5fd8d0597e34ed5898d
This commit is contained in:
@@ -6,7 +6,7 @@ import shutil
|
||||
import stat
|
||||
import unittest
|
||||
|
||||
from common.params import Params, UnknownKeyName
|
||||
from common.params import Params, UnknownKeyName, put_nonblocking
|
||||
|
||||
class TestParams(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@@ -67,5 +67,20 @@ class TestParams(unittest.TestCase):
|
||||
st_mode = os.stat(f"{self.tmpdir}/d/DongleId").st_mode
|
||||
assert (st_mode & permissions) == permissions
|
||||
|
||||
def test_delete_not_there(self):
|
||||
assert self.params.get("CarParams") is None
|
||||
self.params.delete("CarParams")
|
||||
assert self.params.get("CarParams") is None
|
||||
|
||||
def test_put_non_blocking_with_get_block(self):
|
||||
q = Params(self.tmpdir)
|
||||
def _delayed_writer():
|
||||
time.sleep(0.1)
|
||||
put_nonblocking("CarParams", "test", self.tmpdir)
|
||||
threading.Thread(target=_delayed_writer).start()
|
||||
assert q.get("CarParams") is None
|
||||
assert q.get("CarParams", True) == b"test"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user