title: Python websockets send to client and keep connection alive
body: <p>I'm using python websockets: <a href="https://websockets.readthedocs.io/" rel="noreferrer">https://websockets.readthedocs.io/</a></p>
  
  <p>They have a simple client/server example, where the server echoes the client's input back once. The code looks like this:</p>
  
  <p>Client side:</p>
  
  <pre><code># WS client example
  
  import asyncio
  import websockets
  
  async def hello():
      async with websockets.connect(
              'ws://localhost:8765') as websocket:
          name = input("What's your name? ")
  
          await websocket.send(name)
          print(f"&gt; {name}")
  
          greeting = await websocket.recv()
          print(f"&lt; {greeting}")
  
  asyncio.get_event_loop().run_until_complete(hello())
  </code></pre>
  
  <p>Server side:</p>
  
  <pre><code># WS server example
  
  import asyncio
  import websockets
  
  async def hello(websocket, path):
      name = await websocket.recv()
      print(f"&lt; {name}")
  
      greeting = f"Hello {name}!"
  
      await websocket.send(greeting)
      print(f"&gt; {greeting}")
  
  start_server = websockets.serve(hello, 'localhost', 8765)
  
  asyncio.get_event_loop().run_until_complete(start_server)
  asyncio.get_event_loop().run_forever()
  </code></pre>
  
  <p>I want to adapt just the server side only, so that it does the following upon a socket connection:</p>
  
  <ol>
  <li>Send an acknowledgement message to the client. e.g. <code>Hello Client! Please wait for your data.</code></li>
  <li>Keep the connection alive.</li>
  <li>Process some data that takes some time.</li>
  <li>After the data has completed processing, notify the client on the existing websocket connection. e.g. <code>Your data is here!</code></li>
  </ol>
  
  <p>The python websockets documentation doesn't have a code sample which does this.</p>