title: Flask socketio is too slow
body: <p>I have python flask at server end and js on client side. I want to send some logs to client without a request from client. I am trying to implement it with flask socket.io plugin.</p>
  
  <p>Everything looks OK, thanks for below blogs. 
  <a href="https://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent" rel="nofollow noreferrer">https://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent</a></p>
  
  <p>But I can see regular polling going to server and it takes too long to respond. Each polling takes almost 5secs. This delays my other AJAX calls too.
  What could be the reason ?</p>
  
  <p>server side-</p>
  
  <pre><code>@socketio.on('connect', namespace='/test')
  def connect():
      global thread
      with thread_lock:
          if thread is None:
              thread = socketio.start_background_task(target=background_thread)
      socketio.emit('server_msg', 
     {'cause': 'connection', 'status': 'Success', 'count': len(CLIENT.keys())},
                    namespace='/test')
  
  
  @socketio.on('client_msg', namespace='/test')
  def client_msg(msg):
      print(msg)  # TODO: process this msg
  
  
  def background_thread():
      count = 0
      while True:
          socketio.sleep(5)
          count += 1
          socketio.emit('my_response',
                        {'data': 'Server generated event', 'count': count},
                        namespace='/test')
  </code></pre>
  
  <p>Clinet side -</p>
  
  <pre><code>namespace = '/test';
  var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port + namespace);
  
  socket.on('connect', function () {
      socket.emit('client_msg', {cause: 'connection', details: location});
  });
  socket.on('server_msg', function (msg) {
      writeLog('log', 'Received ' + msg.cause + ' ' + msg.status)
  });
   socket.emit('client_msg', {cause: 'connection', details: location});
  </code></pre>
  
  <p>Network Traffic-</p>
  
  <p><a href="https://i.stack.imgur.com/XgD2z.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XgD2z.jpg" alt="enter image description here"></a></p>