Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Various base classes."""
import asyncio
from ._compat import PY_35
class AsyncBase:
def __init__(self, file, loop, executor):
self._file = file
self._loop = loop
self._executor = executor
if PY_35:
@asyncio.coroutine
def __aiter__(self):
"""We are our own iterator."""
return self
@asyncio.coroutine
def __anext__(self):
"""Simulate normal file iteration."""
line = yield from self.readline()
if line:
return line
else:
raise StopAsyncIteration
if PY_35:
from collections.abc import Coroutine