MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / tail_async

Function tail_async

example_code/item_077.py:237–246  ·  view source on GitHub ↗
(handle, interval, write_func)

Source from the content-addressed store, hash-verified

235
236print("Example 8")
237async def tail_async(handle, interval, write_func):
238 loop = asyncio.get_event_loop()
239
240 while not handle.closed:
241 try:
242 line = await loop.run_in_executor(None, readline, handle)
243 except NoNewData:
244 await asyncio.sleep(interval)
245 else:
246 await write_func(line)
247
248
249print("Example 9")

Callers 2

run_tasksFunction · 0.70
tail_fileFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected