backend.py
"""
import uwsgi

def application(env, start_response):
uwsgi.websocket_handshake(env['HTTP_SEC_WEBSOCKET_KEY'],
env.get('HTTP_ORIGIN', ''))
websocket_fd = uwsgi.connection_fd()
while True:
print 'while...'
uwsgi.wait_fd_read(websocket_fd, 3)

#uwsgi.suspend()
#print 'ready...'
#fd = uwsgi.ready_fd()

msg = uwsgi.websocket_recv_nb()
print msg
uwsgi.websocket_send('ok')
"""



$ uwsgi --http-socket :8000 -w backend --need-app --py-autoreload 1 --async
10
*** Starting uWSGI 1.9.20 (32bit) on [Sun Dec  1 13:22:02 2013] ***
compiled with version: 4.8.2 20131017 (Red Hat 4.8.2-1) on 01 December 2013
12:41:11
os: Linux-3.11.8-200.fc19.i686 #1 SMP Wed Nov 13 16:55:29 UTC 2013
nodename: ddlap
machine: i686
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /home/ddarko/projects/websocket
detected binary path: /usr/bin/uwsgi
your processes number limit is 1024
your memory page size is 4096 bytes
detected max file descriptor number: 1024
- async cores set to 10 - fd table size: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :8000 fd 3
Python version: 2.7.5 (default, Oct  8 2013, 12:19:01)  [GCC 4.8.1 20130603
(Red Hat 4.8.1-1)]
Python main interpreter initialized at 0x868a228
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 262192 bytes (256 KB) for 10 cores
*** Operational MODE: async ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x868a228 pid:
12902 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 12902)
spawned uWSGI worker 1 (pid: 12903, cores: 10)
*** DANGER *** async mode without coroutine/greenthread engine loaded !!!
Python auto-reloader enabled




while...

while...
epoll_ctl(): File exists [core/event.c line 520]
Traceback (most recent call last):
  File "./backend.py", line 10, in application
    uwsgi.wait_fd_read(websocket_fd, 3)
IOError: unable to fd 6 to the event queue
epoll_ctl(): No such file or directory [core/event.c line 635]
[pid: 12903|app: 0|req: 1/1] 127.0.0.1 () {38 vars in 588 bytes} [Sun Dec
 1 13:22:07 2013] GET /echo => generated 6 bytes in 32 msecs (HTTP/1.1 101)
4 headers in 167 bytes (0 switches on core 9)




What am I doing wrong?

Frontend connects correctly, sends the data, but I do not receive it at msg
= uwsgi.websocket_recv_nb().
Print returns an empty value.

The loop performs another iteration and the error occurs.

I would like to receive messages asynchronously from the front and reply
"ok" after receiving it.







-- 
Łukasz Wróblewski
http://www.nri.pl/ - Nowoczesne Rozwiązania Internetowe
http://www.hostowisko.pl/ - Profesjonalny i tani hosting
http://www.katalog-polskich-firm.pl/ - Najlepszy darmowy katalog firm
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to