forked from LBRYCommunity/lbry-sdk
schedule_requests is not async
This commit is contained in:
parent
28e4b3eefd
commit
17eeafd62c
2 changed files with 9 additions and 4 deletions
|
@ -424,7 +424,7 @@ class RPCSession(SessionBase):
|
||||||
self.max_errors = 0
|
self.max_errors = 0
|
||||||
self._bump_errors()
|
self._bump_errors()
|
||||||
else:
|
else:
|
||||||
await self.schedule_requests(requests)
|
self.schedule_requests(requests)
|
||||||
|
|
||||||
async def _handle_request(self, request):
|
async def _handle_request(self, request):
|
||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
|
@ -471,7 +471,7 @@ class RPCSession(SessionBase):
|
||||||
async def handle_request(self, request):
|
async def handle_request(self, request):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def schedule_requests(self, requests):
|
def schedule_requests(self, requests):
|
||||||
for request in requests:
|
for request in requests:
|
||||||
self._task_group.add(self._handle_request(request))
|
self._task_group.add(self._handle_request(request))
|
||||||
|
|
||||||
|
|
|
@ -568,7 +568,12 @@ class SessionManager:
|
||||||
async def consumer():
|
async def consumer():
|
||||||
while True:
|
while True:
|
||||||
_, fut = await self.priority_queue.get()
|
_, fut = await self.priority_queue.get()
|
||||||
await fut
|
try:
|
||||||
|
await fut
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
log.exception("raised while serving a request. This should never happen.")
|
||||||
await asyncio.gather(*(consumer() for _ in range(self.consumers)))
|
await asyncio.gather(*(consumer() for _ in range(self.consumers)))
|
||||||
|
|
||||||
async def start_other(self):
|
async def start_other(self):
|
||||||
|
@ -888,7 +893,7 @@ class LBRYElectrumX(SessionBase):
|
||||||
self.db: LevelDB = self.bp.db
|
self.db: LevelDB = self.bp.db
|
||||||
self.time_since_last_request = time.perf_counter()
|
self.time_since_last_request = time.perf_counter()
|
||||||
|
|
||||||
async def schedule_requests(self, requests):
|
def schedule_requests(self, requests):
|
||||||
for request in requests:
|
for request in requests:
|
||||||
current = time.perf_counter()
|
current = time.perf_counter()
|
||||||
elapsed = current - self.time_since_last_request
|
elapsed = current - self.time_since_last_request
|
||||||
|
|
Loading…
Add table
Reference in a new issue