Adds aiocallback in aioread of msgkafka
aioread can now receive an async function as param,
which will be awaited during the consumer msg loop.
This allows of taking full advantage of asyncio.
Also it now passes de kwargs to the callback, instead
of the args. Without this, all params of aioread had to be
passed positionally if you wanted to give additional args
to the callback.
Signed-off-by: Benjamin Diaz <bdiaz@whitestack.com>
Change-Id: I2502c0f2f76643660da1ff24eafa62af2450eacb
diff --git a/osm_common/msgbase.py b/osm_common/msgbase.py
index 8978085..6e6dec0 100644
--- a/osm_common/msgbase.py
+++ b/osm_common/msgbase.py
@@ -15,7 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# import asyncio
from http import HTTPStatus
__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
@@ -56,8 +55,8 @@
def read(self, topic):
raise MsgException("Method 'read' not implemented")
- async def aiowrite(self, topic, key, msg, loop):
+ async def aiowrite(self, topic, key, msg, loop=None):
raise MsgException("Method 'aiowrite' not implemented")
- async def aioread(self, topic, loop):
+ async def aioread(self, topic, loop=None, callback=None, aiocallback=None, **kwargs):
raise MsgException("Method 'aioread' not implemented")