Skip to content

UnboundLocalError in generate_gate if generator yields nothing #3786

@MrBMRBLX

Description

@MrBMRBLX

In fastchat/serve/model_worker.py:

def generate_gate(self, params):
    for x in self.generate_stream_gate(params):
        pass
    return json.loads(x[:-1].decode())

If the generator yields nothing (e.g., an exception before the first yield), x is never defined and this crashes with UnboundLocalError.

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