gevent-socketio

gevent-socketio send message from thread

三世轮回 提交于 2019-12-07 20:20:59
问题 I would like to use gevent-socketio to send messages from a worker thread and update all connected clients on the status of the job. I tried this: from flask import Flask, render_template from flask.ext.socketio import SocketIO, send, emit import threading import time app = Flask(__name__) app.config['SECRET_KEY'] = 'secret!' socketio = SocketIO(app) @socketio.on('message') def handle_message(message): send(message, broadcast=True) @app.route('/') def index(): return render_template('index

gevent-socketio send message from thread

烈酒焚心 提交于 2019-12-06 04:20:23
I would like to use gevent-socketio to send messages from a worker thread and update all connected clients on the status of the job. I tried this: from flask import Flask, render_template from flask.ext.socketio import SocketIO, send, emit import threading import time app = Flask(__name__) app.config['SECRET_KEY'] = 'secret!' socketio = SocketIO(app) @socketio.on('message') def handle_message(message): send(message, broadcast=True) @app.route('/') def index(): return render_template('index.html') def ping_thread(): while True: time.sleep(1) print 'Pinging' send('ping') if __name__ == '__main__

Nginx and Flask-socketio Websockets: Alive but not Messaging?

对着背影说爱祢 提交于 2019-12-04 09:58:51
问题 I've been having a bit of trouble getting Nginx to play nicely with the Python Flask-socketio library (which is based on gevent). Currently, since we're actively developing, I'm trying to get Nginx to just work as a proxy. For sending pages, I can get this to work, either by directly running the flask-socketio app, or by running through gunicorn. One hitch: the websocket messaging does not seem to work. The pages are successfully hosted and displayed. However, when I try to use the websockets

How to emit SocketIO event on the serverside

梦想的初衷 提交于 2019-12-03 06:55:28
问题 I'm running a gevent-socketio Django application. I have something similar to this class @namespace('/connect') class ConnectNamespace(BaseNamespace): def on_send(self, data): # ... However, if I receive the events from the javascript client, everything works and for instance send event is processed correctly I'm a little bit lost if I want to emit some event on the server side. I can do it inside the class with socket.send_packet But now I want to link some event to post_save signal, so I'd

Nginx and Flask-socketio Websockets: Alive but not Messaging?

一世执手 提交于 2019-12-03 03:40:11
I've been having a bit of trouble getting Nginx to play nicely with the Python Flask-socketio library (which is based on gevent). Currently, since we're actively developing, I'm trying to get Nginx to just work as a proxy. For sending pages, I can get this to work, either by directly running the flask-socketio app, or by running through gunicorn. One hitch: the websocket messaging does not seem to work. The pages are successfully hosted and displayed. However, when I try to use the websockets, they do not work. They are alive enough that the websocket thinks it is connected, but they will not

How to emit SocketIO event on the serverside

大兔子大兔子 提交于 2019-12-02 20:32:50
I'm running a gevent-socketio Django application. I have something similar to this class @namespace('/connect') class ConnectNamespace(BaseNamespace): def on_send(self, data): # ... However, if I receive the events from the javascript client, everything works and for instance send event is processed correctly I'm a little bit lost if I want to emit some event on the server side. I can do it inside the class with socket.send_packet But now I want to link some event to post_save signal, so I'd like to send_packet from outside this namespace class, one way of doing this would be

Getting phantomjs, socket.io and gevent-socketio to work together

不问归期 提交于 2019-12-02 03:11:24
问题 I am trying to build an application that utilizes Phantomjs 1.7 (simulating a browser) and create a Python back-end to fire up some events and collect data. The problem is that the two processes Phantomjs and my Python program need to communicate bi-bidirectionally. The problem is that inside page.evaluate I cannot: pass any complex objects such as "fs" (to read from stdin) create a WebSocket to connect to my Python script any other form of inter-process communication is restricted So my

GeventSocketIOWorker has no attribute 'socket'

我的梦境 提交于 2019-12-01 07:36:17
I need to run Django application using gunicorn. I read documentation, and I think I set up everything like I should, but when I run gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker app.wsgi:application I get following error message 2013-02-01 18:25:17 [25394] [INFO] Booting worker with pid: 25394 2013-02-01 18:25:18 [25394] [ERROR] Exception in worker process: Traceback (most recent call last): File ".../app-root/data/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker worker.init_process() File ".../app-root/data/lib/python2.7/site-packages/gunicorn

GeventSocketIOWorker has no attribute 'socket'

亡梦爱人 提交于 2019-12-01 05:01:39
问题 I need to run Django application using gunicorn. I read documentation, and I think I set up everything like I should, but when I run gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker app.wsgi:application I get following error message 2013-02-01 18:25:17 [25394] [INFO] Booting worker with pid: 25394 2013-02-01 18:25:18 [25394] [ERROR] Exception in worker process: Traceback (most recent call last): File ".../app-root/data/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485,