title: Python Thread Pool on a Websocket Client
body: <p>I have a web socket client that is receiving messages from a websocket server using asyncio. </p>
  
  <pre><code>async def web_socket(server):
  async with websockets.connect(server) as websocket:
      message = await websocket.recv()
      t = Thread(target=message_helper.process_message,args(message))
      t.start()
  </code></pre>
  
  <p>The messages from the websocket server come in very quickly and it runs indefinitely. I want to setup a thread pool to ensure I have enough threads. </p>
  
  <p>All the examples I have seen setup a queue (here is one example: <a href="https://www.metachris.com/2016/04/python-threadpool/" rel="nofollow noreferrer">Thread Pool with Queue</a>. The examples that I have seen all have a predefined array of tasks then it starts processing them using the thread pool.</p>
  
  <p>In my example above I don't see how I could implement this? As messages are coming in every second and I want to start a thread to process each message as it comes in. Is there a way to achieve what I am trying to do with a thread pool when I don't have a predefined array of tasks? </p>