# Object list can't be used in 'await' expression

**URL:** <https://discuss.ray.io/t/object-list-cant-be-used-in-await-expression/13517>\
**Category:** Ray Serve\
**Created:** [January 23, 2024, 9:45pm UTC](https://discuss.ray.io/t/object-list-cant-be-used-in-await-expression/13517 "2024-01-23T21:45:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![XBeg9](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/xbeg9/32/5649_2.png) [@XBeg9](https://discuss.ray.io/u/XBeg9)\
**Post date:** [January 23, 2024, 9:45pm UTC](https://discuss.ray.io/t/object-list-cant-be-used-in-await-expression/13517/1 "2024-01-23T21:45:25Z")

</div>

I have 2.9.1 Ray and trying to test micro batching locally, here is a sample code taken from documentation

```auto
from fastapi import FastAPI
from transformers import pipeline

from ray import serve

app = FastAPI()

@serve.deployment
@serve.ingress(app)
class SentimentAnalysis:
    def __init__ (self):
        self._classifier = pipeline("sentiment-analysis")

    @serve.batch(max_batch_size=10, batch_wait_timeout_s=0.1)
    async def classify_batched(self, batched_inputs):
        print("Got batch size:", len(batched_inputs))
        results = self._classifier(batched_inputs)
        return [result["label"] for result in results]

    @app.get("/classify")
    async def classify(self, input_text: str) -> str:
        return await self.classify_batched(input_text)

batched_deployment = SentimentAnalysis.bind()

```

This gives me this error:

```auto
(ProxyActor pid=93832) File "/Users/fed/Projects/AstrumU/ray-testing/.venv/lib/python3.9/site-packages/ray/serve/batching.py", line 498, in batch_wrapper
(ProxyActor pid=93832) return await enqueue_request(args, kwargs)
(ProxyActor pid=93832) File "/Users/fed/Projects/AstrumU/ray-testing/.venv/lib/python3.9/site-packages/ray/serve/batching.py", line 228, in _process_batches
(ProxyActor pid=93832) results = await func_future
(ProxyActor pid=93832) TypeError: object list can't be used in 'await' expression

```

Any ideas what am I missing?

---

<div class="post-metadata">

**Author:** ![Jules\_Damji](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jules_damji/32/4058_2.png) [@Jules\_Damji](https://discuss.ray.io/u/Jules_Damji)\
**Post date:** [January 25, 2024, 8:54pm UTC](https://discuss.ray.io/t/object-list-cant-be-used-in-await-expression/13517/2 "2024-01-25T20:54:48Z")

</div>

@XBeg9 Welcome to the Ray Community and forum for your first post.

Did you try using this pattern documented here: [Dynamic Request Batching — Ray 2.9.1](https://docs.ray.io/en/latest/serve/advanced-guides/dyn-req-batch.html#enable-batching-for-your-deployment)

cc: @Gene @cindy_zhang

---

<div class="post-metadata">

**Author:** ![XBeg9](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/xbeg9/32/5649_2.png) [@XBeg9](https://discuss.ray.io/u/XBeg9)\
**Post date:** [January 25, 2024, 9:08pm UTC](https://discuss.ray.io/t/object-list-cant-be-used-in-await-expression/13517/3 "2024-01-25T21:08:29Z")

</div>

Hi, yes. That’s what I referenced. Actually the problem has been fixed with `async`, you suppose to have in any case even if there is no await inside the function (batch side)

---

<div class="post-metadata">

**Author:** ![Jules\_Damji](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jules_damji/32/4058_2.png) [@Jules\_Damji](https://discuss.ray.io/u/Jules_Damji)\
**Post date:** [January 26, 2024, 7:07pm UTC](https://discuss.ray.io/t/object-list-cant-be-used-in-await-expression/13517/4 "2024-01-26T19:07:39Z")

</div>

@XBeg9 Excellent. I will close this issue. Thanks for taking Ray for a spin and reporting issues.
