@@ -329,7 +329,6 @@ def __init__(
329
329
self .metadata_callback = metadata_callback
330
330
self .log = log or getLogger (__name__ )
331
331
self .lock = Lock ()
332
- self .db_initialized = Event ()
333
332
334
333
async def start (
335
334
self ,
@@ -342,7 +341,6 @@ async def start(
342
341
Arguments:
343
342
task_status: The status to set when the task has started.
344
343
"""
345
-
346
344
self .db_initialized = Event ()
347
345
if from_context_manager :
348
346
assert self ._task_group is not None
@@ -361,7 +359,7 @@ async def start(
361
359
362
360
async def stop (self ) -> None :
363
361
"""Stop the store."""
364
- if self .db_initialized .is_set ():
362
+ if hasattr ( self , "db_initialized" ) and self .db_initialized .is_set ():
365
363
await self ._db .close ()
366
364
await super ().stop ()
367
365
@@ -415,6 +413,8 @@ async def read(self) -> AsyncIterator[tuple[bytes, bytes, float]]:
415
413
Returns:
416
414
A tuple of (update, metadata, timestamp) for each update.
417
415
"""
416
+ if not hasattr (self , "db_initialized" ):
417
+ raise RuntimeError ("ystore is not started" )
418
418
await self .db_initialized .wait ()
419
419
try :
420
420
async with self .lock :
@@ -438,6 +438,8 @@ async def write(self, data: bytes) -> None:
438
438
Arguments:
439
439
data: The update to store.
440
440
"""
441
+ if not hasattr (self , "db_initialized" ):
442
+ raise RuntimeError ("ystore is not started" )
441
443
await self .db_initialized .wait ()
442
444
async with self .lock :
443
445
# first, determine time elapsed since last update
0 commit comments