Skip to content

Commit

Permalink
Internal code restructure (no functional changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Oct 12, 2023
1 parent f3717b2 commit ca9ca5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/engineio/async_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ async def close(self, wait=True, abort=False):
await self.queue.join()

def schedule_ping(self):
async def send_ping():
self.last_ping = None
await asyncio.sleep(self.server.ping_interval)
if not self.closing and not self.closed:
self.last_ping = time.time()
await self.send(packet.Packet(packet.PING))

self.server.start_background_task(send_ping)
self.server.start_background_task(self._send_ping)

async def _send_ping(self):
self.last_ping = None
await asyncio.sleep(self.server.ping_interval)
if not self.closing and not self.closed:
self.last_ping = time.time()
await self.send(packet.Packet(packet.PING))

async def _upgrade_websocket(self, environ):
"""Upgrade the connection from polling to websocket."""
Expand Down
16 changes: 8 additions & 8 deletions src/engineio/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ def close(self, wait=True, abort=False):
self.queue.join()

def schedule_ping(self):
def send_ping():
self.last_ping = None
self.server.sleep(self.server.ping_interval)
if not self.closing and not self.closed:
self.last_ping = time.time()
self.send(packet.Packet(packet.PING))

self.server.start_background_task(send_ping)
self.server.start_background_task(self._send_ping)

def _send_ping(self):
self.last_ping = None
self.server.sleep(self.server.ping_interval)
if not self.closing and not self.closed:
self.last_ping = time.time()
self.send(packet.Packet(packet.PING))

def _upgrade_websocket(self, environ, start_response):
"""Upgrade the connection from polling to websocket."""
Expand Down

0 comments on commit ca9ca5b

Please sign in to comment.