<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def open_websocket(url: str, headers: Optional[list] = None, subprotocols: Optional[list] = None):
 """ Opens a websocket. """

    ws = await create_websocket(
        url, headers=headers, subprotocols=subprotocols)
    try:
        yield ws
    finally:
        await ws.close()