Skip to content

Commit

Permalink
minor async cleanup (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketmaurya authored Jun 20, 2024
1 parent 51b3358 commit ec05a06
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/litserve/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,13 @@ def get_from_pipe(self, read):

async def data_reader(self, read):
data_available = asyncio.Event()
asyncio.get_event_loop().add_reader(read.fileno(), data_available.set)
loop = asyncio.get_event_loop()
loop.add_reader(read.fileno(), data_available.set)

if not read.poll():
await data_available.wait()
data_available.clear()
asyncio.get_event_loop().remove_reader(read.fileno())
loop.remove_reader(read.fileno())
return read.recv()

async def win_data_streamer(self, read, write, send_status=False):
Expand Down

0 comments on commit ec05a06

Please sign in to comment.