David Montgomery | 28 May 08:34 2015
Picon

Why?

Why?

UWSGI_PROFILE=gevent pip install uwsgi
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 61, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
    from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead

_______________________________________________
uWSGI mailing list
uWSGI@...
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
Илья | 27 May 03:40 2015
Picon

Mapping processes to specific cpu cores

Hi!

I have 2 sites on my server with 4 cpu cores.
For both of them I use workers=2 and cpu-affinity=1 so workers are
mapped to cpu 0 and 1 like that:
----------
spawned uWSGI master process (pid: 6588)
spawned uWSGI worker 1 (pid: 6589, cores: 1)
mapping worker 1 to CPUs:
spawned uWSGI worker 2 (pid: 6590, cores: 1)
mapping worker 2 to CPUs: 1
----------

I don't want to use 4 workers to reduce memory usage so I wonder if i
can somehow map workers to specific cpu cores?
Taking example above, would be nice to have 0 and 1 cpu mapped to
workers of the first site and 2 and 3 for the second one.

Also I found some useful (but not enough) info here:
http://lists.unbit.it/pipermail/uwsgi/2011-March/001594.html

Thanks.
Jerry OELoo | 22 May 11:42 2015
Picon

Why it will log twice

Hi.
I use StreamHandler to format log information and store it into a log
file. Now it works fine.

from logging import StreamHandler
file_handler = StreamHandler()
formatter = logging.Formatter("%(asctime)s.%(msecs)06d [%(levelname)s]
%(message)s",
    "%d/%m/%Y %H:%M:%S")
file_handler.setFormatter(formatter)
app.logger.setLevel(logging.DEBUG)
app.logger.addHandler(file_handler)

But when I check log file, I found it is strange that it will record
two info in log file.

22/05/2015 09:21:21.000018 [DEBUG] Query()                    #first log
DEBUG:uwsgi_file__ws_uwsgi_webservice_my_test:Query()        #second log

In my code, I only call:.
app.logger.debug('Query()')

So, The first log is I want, but second one is not need, how can I
disable this log.
Thanks!

Best Regards
Jerry
--

-- 
Rejoice,I Desire!
Damjan Georgievski | 21 May 00:33 2015
Picon

http status and response time in custom logger

I'm using msgpack logging to logstash, as here
http://uwsgi-docs.readthedocs.org/en/latest/LogEncoders.html#the-msgpack-encoder

Is it possible to add fields for the response time and http status to
the log message structure?

My current encoder is set as:
log-encoder     =  msgpack:logstash
map:4|str:message|msg|str:hostname|str:%h|str
:version|str:%V|str:appname|str:%n

--

-- 
damjan
Andrey Shmigelsky | 20 May 14:50 2015
Picon

Key Value DB in shared memory

I'm trying to improve my application performance and want to get ride of unnecessary requests to database. I have couple of counters that I can allow to be stored temporary. Currently, my implementation works well but can't be scaled, that is why I need another solution. 

So to the problem:

1. I receive requests with JSON data from which I create ID for redis like "prefix:USA:123122"
2. Instead of going to that key in Redis, I want to go straight to shared memory and increment the value. To do it, I need to know the position. I do md5 hashing to that key, which gives me in that case 569b6f34b5275a30c7b69a6be69cb306
3. Take first 7 characters of that md5 and convert it to decimal which gives me 90814195
4. I do uwsgi.sharedarea_inc32(0, 90814195)
5. And where I need to know the value I do uwsgi.sharedarea_read32(0, 90814195)

The problem is that first seven characters is not enough, I start to see duplicate first seven characters of md5 on different keys but I can't give more memory to shared area and use 8 chars. 

So I thought is there a way to create a simple key value db inside shared area, read it on every request, update the counter and put it back. Something like pickle python dictionary to shared memory and fill other space with zeros. The problem with such approach is that increments are not atomic.

Is uWSGI already provide something to solve my problem?
 
_______________________________________________
uWSGI mailing list
uWSGI@...
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
Dorian Hoxha | 20 May 14:30 2015
Picon

How to access some GEOIP variables like country, city when using the GEOIP plugin ?

I think I tried everyway possible, add-header, add-var etc. but I couldn't access them. What should I do in the config to get these values on each request ?

Thank you
_______________________________________________
uWSGI mailing list
uWSGI@...
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
Andrew Stuart | 20 May 09:17 2015
Picon

Is embedding code supported in Python 3?

I am trying to embed Python 3 code.

I found this old message from 2011 which says it is only supported on Python 2.

http://lists.unbit.it/pipermail/uwsgi/2011-October/002785.html

Has it since been upgraded to support Python 3?

thanks
Andrew Stuart | 20 May 08:41 2015
Picon

Embedding files fails when using x=dirname format

When I embed files using the format:

embed_files = x=dirname

The build fails.  See below for the error messages.  The error messages are saying they cannot find the files. 
It is looking in build/ directory for the files, but in fact those files are in the current directory.  When I
move all the files down into build and re-run the make command it works fine because it finds the files it is
looking for.

(venv3.4) ubuntu <at> contiki:~/uwsgi-2.0.10$ cat buildconf/flask.ini
[uwsgi]
main_plugin = python
inherit = base
bin_name = myapp
plugin_dir = /home/ubuntu/uwsgi-2.0.10/plugins
embed_config = /home/ubuntu/uwsgi-2.0.10/flaskconfig.ini
embed_files = bootstrap.py,myapp.py,flask=/home/ubuntu/uwsgi-2.0.10/venv3.4/lib/python3.4/site-packages/flask,itsdangerous=/home/ubuntu/uwsgi-2.0.10/venv3.4/lib/python3.4/site-packages/itsdangerous.py,jinja2=/home/ubuntu/uwsgi-2.0.10/venv3.4/lib/python3.4/site-packages/jinja2,markupsafe=/home/ubuntu/uwsgi-2.0.10/venv3.4/lib/python3.4/site-packages/markupsafe,werkzeug=/home/ubuntu/uwsgi-2.0.10/venv3.4/lib/python3.4/site-packages/werkzeug

(venv3.4) ubuntu <at> contiki:~/uwsgi-2.0.10$

objcopy --redefine-sym
_binary__home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug_shared_more_png_end=_binary_werkzeug_debug_shared_more_png_end build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug_shared_more_png.o
objcopy: warning: could not create temporary file whilst copying
'build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug_shared_more_png.o',
(error: No such file or directory)
ld -r -b binary -o
_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache_____init___cpython_34_pyc.o /home/ubuntu/uwsgi-2.0.10/venv3.4/lib/python3.4/site-packages/werkzeug/debug/__pycache__/__init__.cpython-34.pyc
objcopy --redefine-sym
_binary__home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache_____init___cpython_34_pyc_start=_binary_werkzeug_debug___pycache_____init___cpython_34_pyc_start build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache_____init___cpython_34_pyc.o
objcopy: warning: could not create temporary file whilst copying
'build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache_____init___cpython_34_pyc.o',
(error: No such file or directory)
objcopy --redefine-sym
_binary__home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache_____init___cpython_34_pyc_end=_binary_werkzeug_debug___pycache_____init___cpython_34_pyc_end build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache_____init___cpython_34_pyc.o
objcopy: warning: could not create temporary file whilst copying
'build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache_____init___cpython_34_pyc.o',
(error: No such file or directory)
ld -r -b binary -o
_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache___console_cpython_34_pyc.o /home/ubuntu/uwsgi-2.0.10/venv3.4/lib/python3.4/site-packages/werkzeug/debug/__pycache__/console.cpython-34.pyc
objcopy --redefine-sym
_binary__home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache___console_cpython_34_pyc_start=_binary_werkzeug_debug___pycache___console_cpython_34_pyc_start build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache___console_cpython_34_pyc.o
objcopy: warning: could not create temporary file whilst copying
'build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache___console_cpython_34_pyc.o',
(error: No such file or directory)
objcopy --redefine-sym
_binary__home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache___console_cpython_34_pyc_end=_binary_werkzeug_debug___pycache___console_cpython_34_pyc_end build/_home_ubuntu_uwsgi_2_0_10_venv3_4_lib_python3_4_site_packages_werkzeug_debug___pycache___console_cpython_34_pyc.o
objcopy: warning: could not create temporary file whilst copying
Andrew Stuart | 20 May 05:10 2015
Picon

no request plugin is loaded, you will not be able to manage requests.

Hello

I am following the instructions here: http://uwsgi-docs.readthedocs.org/en/latest/Embed.html

I create the files as instructed:

ubuntu <at> contiki:~/uwsgi-2.0.10$ cat buildconf/flask.ini
[uwsgi]
inherit = default
bin_name = myapp
embed_files = bootstrap.py,myapp.py
plugin_dir = /home/ubuntu/uwsgi-2.0.10/plugins
embed_config = /home/ubuntu/uwsgi-2.0.10/flaskconfig.ini

ubuntu <at> contiki:~/uwsgi-2.0.10$ cat flaskconfig.ini
[uwsgi]
http-socket = 127.0.0.1:3031
import = sym://bootstrap_py
module = myapp:app

I run ./myapp and it says "no request plugin is loaded, you will not be able to manage requests."

ubuntu <at> contiki:~/uwsgi-2.0.10$ ./myapp
*** Starting uWSGI 2.0.10 (64bit) on [Tue May 19 23:08:42 2015] ***
compiled with version: 4.8.2 on 19 May 2015 23:07:50
os: Linux-3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015
nodename: contiki
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /home/ubuntu/uwsgi-2.0.10
detected binary path: /home/ubuntu/uwsgi-2.0.10/myapp
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 14658
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72760 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
no request plugin is loaded, you will not be able to manage requests.
you may need to install the package for your language of choice, or simply load it with --plugin.
!!!!!!!!!!! END OF WARNING !!!!!!!!!!
spawned uWSGI worker 1 (and the only) (pid: 11086, cores: 1)
^Cubuntu <at> contiki:~/uwsgi-2.0.10$
Andrew Stuart | 20 May 03:08 2015
Picon

How to access embedded files?

Hello

I have embedded a directory of files via embed_files =

Can I access these files via HTTP?

What is the correct syntax to access them?

thanks
Faina Low | 18 May 22:00 2015
Picon

Redis hangs when using it with uwsgi

Hello all,

When I use redis with gevent and uwsgi, some of my processes seem to hang. I’ve isolated the error I’m getting in the code snippet below.

When I use the following command ( uwsgi --gevent 100 --socket 0.0.0.0:8000 --protocol=http -w testapp -p 4 ) to have uwsgi run 4 workers I expected 'done' to be print 4 time to standard output, but it doesn't. If I remove the monkey patching, things works fine and I get the 'done' to print 4 times. When I use one process, everything works find, but anymore then that and I would get the hanging problem.

Any help would be appreciated. 

from gevent import monkey; monkey.patch_all() import redis, gevent from flask import Flask application = Flask(__name__) r = redis.StrictRedis(host='localhost', port=6379, db=0) def setup_cache(): r.set('a', 'b') print 'done' <at> application.route('/') def hello_world(): return 'Hello World!' gevent.spawn(setup_cache) if __name__ == "__main__": application.run()
_______________________________________________
uWSGI mailing list
uWSGI@...
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Gmane