title: Python/Flasks/Socketio, socketio.emit(...) doesn't emit
body: <p>i'm having trouble to use flasks socketio, it seems that when I call <code>socketio.emit('my event', 'my message')</code> it doesn't emit any event at all...</p>
  
  <p>So this is my setup:</p>
  
  <pre><code>|
  +--/static     &lt;-- css/js/etc.
  |
  +--/templates  &lt;- only home.html
  |
  +--flask_app.py
  </code></pre>
  
  <p><code>home.html</code> is just a simple chat window with these scritps and it works without any problem:</p>
  
  
  
  <pre><code>&lt;script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" charset="utf-8"&gt;
      var socket = io.connect('http://' + document.domain + ':' + location.port);
      $('form').submit(function(){
          socket.emit('request', $('#m').val());
          $('#m').val('');
          return false;
      });
  
      socket.on('message', function(message){
          $('#messages').append($('&lt;li&gt;').text(message));
          console.log('Message received');
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>I have a function that tracks changes in my models data, and emits a event
  to notify everyone that data has changed, the problem is that when I call
  <code>socketio.emit(...)</code> nobody gets the notification.</p>
  
  <pre><code>from flask import Flask, render_template
  from flask_socketio import SocketIO, emit
  from flask_sqlalchemy import SQLAlchemy
  from sqlalchemy import event
  
  app = Flask(__name__)
  
  # App configuration
  app.config['SECRET_KEY'] = 'somekey!'
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
  app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
  
  socketio = SocketIO(app)
  
  db = SQLAlchemy(app)
  
  # Simple model
  class Person(db.Model):
  
  
      __tablename__ = 'persons'
  
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String)
  
      @property
      def serialize(self):
          return {
              'id': self.id,
              'name': self.name
          }
  
  db.create_all()
  
  @app.route('/')
  def index():
      return render_template('home.html')
  
  # Whenever a user emits 'request' event via javascripts socketio
  @socketio.on('request')
  def handle_request(message):
      emit('message', str(message), broadcast=True)
  
  # Whenever values are changed in Persons table
  @event.listens_for(Person, 'after_update')
  def receive_after_update(mapper, connection, target):
      print(str(target.serialize))
      socketio.emit('message', str(target.serialize)) # &lt;------ This doesn't emit any event...
  
  if __name__ == '__main__':
      socketio.run(app, host='0.0.0.0', port=8000, debug=True)
  </code></pre>
  
  <p>Does anyone know what is the issue?
  Thanks</p>
  
  <h2>Edit</h2>
  
  <p>Forgot to mention that I do changes in database via console and it prints out <code>print(str(target.serialize))</code></p>