diff --git a/lbrynet/extras/daemon/storage.py b/lbrynet/extras/daemon/storage.py index 40e388079..8e7ba8e9e 100644 --- a/lbrynet/extras/daemon/storage.py +++ b/lbrynet/extras/daemon/storage.py @@ -132,10 +132,11 @@ class SQLiteStorage(SQLiteMixin): ); """ - def __init__(self, path): + def __init__(self, path, loop=None): super().__init__(path) self.content_claim_callbacks = {} self.check_should_announce_lc = None + self.loop = loop or asyncio.get_event_loop() async def open(self): await super().open() @@ -219,7 +220,7 @@ class SQLiteStorage(SQLiteMixin): def should_single_announce_blobs(self, blob_hashes, immediate=False): def set_single_announce(transaction): - now = asyncio.get_event_loop().time() + now = self.loop.time() for blob_hash in blob_hashes: if immediate: transaction.execute( @@ -234,7 +235,7 @@ class SQLiteStorage(SQLiteMixin): def get_blobs_to_announce(self): def get_and_update(transaction): - timestamp = asyncio.get_event_loop().time() + timestamp = self.loop.time() if conf.settings['announce_head_blobs_only']: r = transaction.execute( "select blob_hash from blob " @@ -784,7 +785,7 @@ class SQLiteStorage(SQLiteMixin): if success: return self.db.execute( "insert or replace into reflected_stream values (?, ?, ?)", - (sd_hash, reflector_address, asyncio.get_event_loop().time()) + (sd_hash, reflector_address, self.loop.time()) ) return self.db.execute( "delete from reflected_stream where sd_hash=? and reflector_address=?", @@ -796,7 +797,7 @@ class SQLiteStorage(SQLiteMixin): "select s.sd_hash from stream s " "left outer join reflected_stream r on s.sd_hash=r.sd_hash " "where r.timestamp is null or r.timestamp < ?", - asyncio.get_event_loop().time() - conf.settings['auto_re_reflect_interval'] + self.loop.time() - conf.settings['auto_re_reflect_interval'] )