From d30e7cd29e6e87170af0315a27c65ec2f8d585ff Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 7 Jan 2019 17:26:06 -0500 Subject: [PATCH] use loop.time() instead of reactor.seconds() in SQLite storage --- lbrynet/extras/daemon/storage.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lbrynet/extras/daemon/storage.py b/lbrynet/extras/daemon/storage.py index 18f618f04..ec050ff5a 100644 --- a/lbrynet/extras/daemon/storage.py +++ b/lbrynet/extras/daemon/storage.py @@ -134,8 +134,6 @@ class SQLiteStorage(SQLiteMixin): def __init__(self, path): super().__init__(path) - from twisted.internet import reactor - self.clock = reactor self.content_claim_callbacks = {} self.check_should_announce_lc = None @@ -221,7 +219,7 @@ class SQLiteStorage(SQLiteMixin): def should_single_announce_blobs(self, blob_hashes, immediate=False): def set_single_announce(transaction): - now = self.clock.seconds() + now = asyncio.get_running_loop().time() for blob_hash in blob_hashes: if immediate: transaction.execute( @@ -236,7 +234,7 @@ class SQLiteStorage(SQLiteMixin): def get_blobs_to_announce(self): def get_and_update(transaction): - timestamp = self.clock.seconds() + timestamp = asyncio.get_running_loop().time() if conf.settings['announce_head_blobs_only']: r = transaction.execute( "select blob_hash from blob " @@ -786,7 +784,7 @@ class SQLiteStorage(SQLiteMixin): if success: return self.db.execute( "insert or replace into reflected_stream values (?, ?, ?)", - (sd_hash, reflector_address, self.clock.seconds()) + (sd_hash, reflector_address, asyncio.get_running_loop().time()) ) return self.db.execute( "delete from reflected_stream where sd_hash=? and reflector_address=?", @@ -798,7 +796,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 < ?", - self.clock.seconds() - conf.settings['auto_re_reflect_interval'] + asyncio.get_running_loop().time() - conf.settings['auto_re_reflect_interval'] )