Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raw socket error #960

Open
yueyoum opened this issue Jul 10, 2015 · 2 comments
Open

raw socket error #960

yueyoum opened this issue Jul 10, 2015 · 2 comments

Comments

@yueyoum
Copy link
Contributor

yueyoum commented Jul 10, 2015

I try using uwsgi's raw socket mode, I have the following code

import os                                                                            

def application(fd):                                                             
    print "connection:", fd                                                          
    os.write(fd, "Hi, uWSGI and Python")                                             
    print "done"                                                                     
    data = os.read(fd, 100)                                                          
    print "got:", data                                                               

and i start uwsgi with this arguments:

uwsgi --raw-socket :7000 --python-raw test.py --master

then, in another terminal, I try connect to the uwsgi's raw socket:

wang[20:22][~]$ python
Python 2.7.6 (default, Jun 22 2015, 18:00:18) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> s = socket.socket()
>>> s.connect(("127.0.0.1", 7000))
>>> 

But, I got this Error:

wang[20:22][/tmp]$ uwsgi --raw-socket :7000 --python-raw test.py --master
*** Starting uWSGI 2.0.11 (32bit) on [Fri Jul 10 20:22:54 2015] ***
compiled with version: 4.9.2 on 02 July 2015 17:15:33
os: Linux-3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:28:41 UTC 2015
nodename: wang-X230
machine: i686
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /tmp
detected binary path: /usr/local/bin/uwsgi
your processes number limit is 94605
your memory page size is 4096 bytes
detected max file descriptor number: 100000
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :7000 fd 3
Python version: 2.7.6 (default, Jun 22 2015, 18:03:54)  [GCC 4.8.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x8f57b40
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 127976 bytes (124 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 569)
spawned uWSGI worker 1 (pid: 570, cores: 1)

connection: 6
done
Traceback (most recent call last):
  File "test.py", line 16, in application
    data = os.read(fd, 100)
OSError: [Errno 11] Resource temporarily unavailable


Why ?

@unbit
Copy link
Owner

unbit commented Jul 10, 2015

The uWSGI sockets are opened in non-blocking mode. You need to deal with EAGAIN or use an i/o notification system like select/poll/epoll/kqueue

@yueyoum
Copy link
Contributor Author

yueyoum commented Jul 20, 2015

How to use it? Is there any tutorial ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants