Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pytrickle/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ async def control_loop(self, done: asyncio.Event) -> AsyncGenerator[dict, None]:
data = json.loads(params)
if data == keepalive_message:
# Ignore periodic keepalive messages
logger.info("Received control keepalive message")
continue

logger.info("Received control message with params: %s", data)
Expand Down
14 changes: 13 additions & 1 deletion pytrickle/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,19 @@ async def preconnect(self) -> Optional[aiohttp.ClientResponse]:
url = f"{self.base_url}/{idx}"
logger.info(f"Trickle sub resetting index to leading edge {url}")
resp.release()
# Continue immediately
# Continue immediately after small timeout for control url
if "control" in self.base_url:
await asyncio.sleep(1*attempt)
if attempt > 1:
if idx != -1:
idx = str(int(idx) + 1)
resp2 = await self.session.get(f"{self.base_url}/{idx}", headers={'Connection': 'close'})
if resp2.status == 200:
resp.release()
return resp2
else:
resp2.release()
await asyncio.sleep(1 * attempt)
continue

body = await resp.text()
Expand Down