uWSGI wizard uses non-portable syscall #758

Closed
Borkason opened this Issue Mar 24, 2013 · 7 comments

Projects

None yet

1 participant

@Borkason
Member

Original author: alobbs (December 02, 2010 16:54:47)

This happens on (at least) MacOS X:

Traceback (most recent call last):
File "/Users/alo/prog/cherokee/admin//server.py", line 253, in ?
import PageVServers
File "/Users/alo/prog/cherokee/admin/PageVServers.py", line 30, in ?
import Wizard
File "/Users/alo/prog/cherokee/admin/Wizard.py", line 269, in ?
init()
File "/Users/alo/prog/cherokee/admin/Wizard.py", line 265, in init
CTK.load_module (w, 'wizards')
File "/Users/alo/prog/cherokee/admin/CTK/CTK/Plugin.py", line 212, in load_module
return imp.load_source (name, fullpath)
File "/Users/alo/prog/cherokee/admin/wizards/uwsgi.py", line 70, in ?
UWSGI_CPUS = os.sysconf('SC_NPROCESSORS_ONLN')

ValueError: unrecognized configuration name

Original issue: http://code.google.com/p/cherokee/issues/detail?id=1060

@Borkason
Member

From roberto....@gmail.com on December 02, 2010 18:04:27
What version of OSX ?

On Snow Leopard (i386/x86_64) i can get the value without problems
(tested with python2.5 and python2.6)

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import os
os.sysconf('SC_NPROCESSORS_ONLN')
2

@Borkason
Member

From alobbs on December 02, 2010 18:09:52
Right, it seems Python 2.4 did not support it yet:

$ python
Python 2.4.6 (#​1 (Github: #81), Oct 15 2009, 11:10:21)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import os
os.sysconf('SC_NPROCESSORS_ONLN')
Traceback (most recent call last):
File "", line 1, in ?
ValueError: unrecognized configuration name

@Borkason
Member

From roberto....@gmail.com on December 02, 2010 18:18:02
Right, i will put this part under try/except block (with fallback to one cpu)

Thanks a lot

@Borkason
Member

From alobbs on December 02, 2010 18:38:24
I have just committed a patch about it (r5871). I do hope it did not break anything.

@Borkason
Member

From alobbs on December 02, 2010 19:47:11
It should be fixed in trunk now.
Thanks Roberto!!!

@Borkason
Member

From mac.dash...@gmail.com on December 05, 2010 00:57:15
I get this bug on a system with Python 2.5.4, Mac OS X 10.4.11. I can't see r5871, but this patch theoretically should give the right number of processors even if >1:

*** cherokee-1.0.12/admin/wizards/uwsgi_orig.py Sat Dec 4 17:50:47 2010
--- cherokee-1.0.12/admin/wizards/uwsgi.py Sat Dec 4 19:35:46 2010


*** 67,73 ****
PREFIX = 'tmp!wizard!uwsgi'
URL_APPLY = r'/wizard/vserver/uwsgi/apply'

! UWSGI_CPUS = os.sysconf('SC_NPROCESSORS_ONLN')
UWSGI_CMDLINE_AUTOMAGIC = "-M -p %d -z %s -L -l %d" % (UWSGI_CPUS*2, CTK.cfg.g
et_val('server!timeout'), socket.SOMAXCONN)
UWSGI_DEFAULT_CONFS = ('.xml', '.ini', '.yml',)
UWSGI_MAGIC_CONFS = ('.wsgi', '.py', '.psgi', '.pl', '.lua', '.ws', '.ru', '.r
b',)
--- 67,77 ----
PREFIX = 'tmp!wizard!uwsgi'
URL_APPLY = r'/wizard/vserver/uwsgi/apply'

! if os.sysconf_names.has_key("SC_NPROCESSORS_ONLN"):
! UWSGI_CPUS = os.sysconf("SC_NPROCESSORS_ONLN")
! else:
! # Some versions of Mac OS X or Python
! UWSGI_CPUS = int(os.popen2("sysctl -n hw.ncpu")[1].read())
UWSGI_CMDLINE_AUTOMAGIC = "-M -p %d -z %s -L -l %d" % (UWSGI_CPUS*2, CTK.cfg.g
et_val('server!timeout'), socket.SOMAXCONN)
UWSGI_DEFAULT_CONFS = ('.xml', '.ini', '.yml',)
UWSGI_MAGIC_CONFS = ('.wsgi', '.py', '.psgi', '.pl', '.lua', '.ws', '.ru', '.r
b',)

I've tested this with Python 2.5.4, Mac OS X 10.4.11, on a PPC G3 Mac with one CPU. Some old PPC Macs do have more than one processor!

--Steve

@Borkason
Member

From alobbs on December 05, 2010 08:00:36
Steve, A similar patch was already committed a few days ago:
http://svn.cherokee-project.com/browser/cherokee/trunk/admin/wizards/uwsgi.py#L134

It will be shipped with Cherokee 1.0.13.
Thanks a million for the patch anyway!!

@Borkason Borkason closed this Mar 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment