Skip to content

async_predict error when coroutines too high #34

@Liangtaiwan

Description

@Liangtaiwan

async_predict error when coroutines too high

for example

 async def speed_testing_async_encode(self, batch_size: int = 32) -> np.ndarray:
        '''
        This function is for async_encode speed test.
        You should NOT use this for normal encoding.
        '''
        coros = []
        max_len = self.get_pad_maxlen()
        for _ in range(10000):
            coro = self.client.async_predict(
                data=[
                    PredictInput(name='x', value=[list(range(max_len))]),
                    PredictInput(name='seqlen', value=[max_len]),
                ],
                output_names=['latent_vector'],
                model_name=self.model_name,
                model_signature_name='encode',
            )
            coros.append(coro)
        await asyncio.gather(*coros)
def get_pad_maxlen(self):
    for step_info in self.pipe._step_info:
        if step_info['op_name'] == 'Pad':
            return step_info['op_kwargs']['maxlen']

    raise KeyError("Can't find any `Pad` operation in pipe!")

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