我在尝试执行使用多处理包的python程序时遇到错误:
File "/usr/local/lib/python2.6/multiprocessing/__init__.py", line 178, in RLock
return RLock()
File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line 142, in __init__
SemLock.__init__(self, RECURSIVE_MUTEX, 1, 1)
File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line 49, in __init__
sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
OSError: [Errno 13] Permission denied
Run Code Online (Sandbox Code Playgroud)
看起来用户没有访问共享内存的权限.使用root权限执行时,它可以正常工作.
是否有任何解决方案以普通用户(非root用户身份)运行它?
Python版本2.6.2,操作系统是Linux 2.6.18(CentOS版本5.4),它是VPS机器.
有人可以解释守护进程模式下的apache mod_wsgi和线程模式下的django fastcgi之间的区别.我认为它们都使用线程来实现并发性. 假设我使用nginx作为apache mod_wsgi的前端.
更新:
我正在比较内置fastcgi(./ manage.py方法=线程maxchildren = 15)的django和'daemon'模式下的mod_wsgi(WSGIDaemonProcess示例threads = 15).他们都使用线程并获得GIL,对吗?
UPDATAE 2:
所以,如果它们都相似,那么apache mod_wsgi对fastcgi有什么好处.我看到fastcgi的这些优点:
UPDATAE 3:
我现在对nginx + uwsgi很满意.
UPDATAE 4:
我现在对nginx + gunicorn很满意:)
优点和缺点?
我个人正在为我的django项目使用buildout,但考虑到简单地切换到virtualenv + pip.
在我的django项目中,我有以下LOGGING配置:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(name)s %(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'null': {
'level': 'DEBUG',
'class':'django.utils.log.NullHandler',
},
'sentry': {
'level': 'DEBUG',
'class': 'sentry.client.handlers.SentryHandler',
'formatter': 'verbose'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'django.db.backends': {
'handlers': ['console'],
'level': 'INFO',
'propagate': False,
},
'': {
'level': 'ERROR',
'handlers': ['console'],
},
},
}
Run Code Online (Sandbox Code Playgroud)
在运行时manage.py migrate
我仍然在控制台中有很多调试内容,例如:
DEBUG …
Run Code Online (Sandbox Code Playgroud) 您可以向我推荐什么样的python RPC框架/ lib?该体系结构是客户端 - 服务器,服务器应该承受高负载,并且连接通过ssl进行隧道传输.我用google搜索了pyro,twisted.spread,rpyc这样的东西.
我正在尝试为django-test-utils makefixture命令添加泛型关系和一对一关系支持,这里是源代码http://github.com/ericholscher/django-test-utils/blob/master/test_utils /management/commands/makefixture.py
有人有想法如何做到这一点?或者可能有另一种工具用于:
./manage.py dumpcmd User[:10] > fixtures.json
Run Code Online (Sandbox Code Playgroud) 我怎样才能在django中执行这样的查询:
SELECT * FROM keywords_keyword WHERE id not in (SELECT keyword_id FROM sites_pagekeyword)
Run Code Online (Sandbox Code Playgroud)
在最新的SVN版本中,我们可以使用:
keywords = Keyword.objects.raw('SELECT * FROM keywords_keyword WHERE id not in (SELECT keyword_id FROM sites_pagekeyword)')
Run Code Online (Sandbox Code Playgroud)
但RawQuerySet不支持filter(),count(),索引和其他东西.还有另外一种方法吗?
python ×6
django ×5
buildout ×1
deployment ×1
fastcgi ×1
fixtures ×1
frameworks ×1
linux ×1
logging ×1
mod-wsgi ×1
pip ×1
rpc ×1
sql ×1
virtualenv ×1