WebSocket Client with Python Create a new File “client.py” and import the packages as we did in our server code . Now let’s create a Python asynchronous function (also called coroutine). async def test(): We will use the connect function from the WebSockets module to build a WebSocket client connection.