Skip to content

Part 3 Chapter 15 request_batching_server.py #85

Closed
@Vedant-R

Description

@Vedant-R

Hi,

This is an exceptional solution provided for async deployment and model serving.

I wanted to enquire if there are examples of unit tests for this. I have been continuously struggling with unit tests for sanic async post method with the following error:

async with self.queue_lock:
AttributeError: __aenter__

I am getting this error for the line:

58 async with self.queue_lock:
59        if len(self.queue) >= MAX_QUEUE_SIZE:

The test I am trying:

import json
import pytest
from ..app import app

@pytest.mark.asyncio
async def test_basic_post():
    _, response = await app.asgi_client.post("/predict", data=json.dumps(INPUT), headers=HEADERS)
    print(response)

Please do let me know if anyone has come across this and have a solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions