Skip to content

Commit

Permalink
fixes #26: threading error during exit
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed May 13, 2014
1 parent 52bcba3 commit aa6f65f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions example/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from gevent import monkey
monkey.patch_all()

import time
from threading import Thread
from flask import Flask, render_template, session, request
from flask.ext.socketio import SocketIO, emit, join_room, leave_room

app = Flask(__name__)
app.debug = True
app.debug = False
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)

Expand Down Expand Up @@ -62,8 +65,8 @@ def leave(message):
def send_room_message(message):
session['receive_count'] = session.get('receive_count', 0) + 1
emit('my response',
{'data': message['data'], 'count': session['receive_count']},
room=message['room'])
{'data': message['data'], 'count': session['receive_count']},
room=message['room'])


@socketio.on('connect', namespace='/test')
Expand Down
2 changes: 2 additions & 0 deletions flask_socketio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __call__(self, environ, start_response):
else:
return self.wsgi_app(environ, start_response)


class SocketIO(object):
def __init__(self, app=None):
if app:
Expand Down Expand Up @@ -214,6 +215,7 @@ def test_client(self, app, namespace=None):
def emit(event, *args, **kwargs):
return request.namespace.emit(event, *args, **kwargs)


def send(message, json=False, namespace=None, callback=None, broadcast=False, room=None):
return request.namespace.send(message, json, namespace, callback, broadcast, room)

Expand Down
3 changes: 3 additions & 0 deletions test_socketio.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from gevent import monkey
monkey.patch_all()

import unittest
import coverage

Expand Down

0 comments on commit aa6f65f

Please sign in to comment.