我正在运行Scrapyd并在同时启动4个蜘蛛时遇到一个奇怪的问题.
2012-02-06 15:27:17+0100 [HTTPChannel,0,127.0.0.1] 127.0.0.1 - - [06/Feb/2012:14:27:16 +0000] "POST /schedule.json HTTP/1.1" 200 62 "-" "python-requests/0.10.1"
2012-02-06 15:27:17+0100 [HTTPChannel,1,127.0.0.1] 127.0.0.1 - - [06/Feb/2012:14:27:16 +0000] "POST /schedule.json HTTP/1.1" 200 62 "-" "python-requests/0.10.1"
2012-02-06 15:27:17+0100 [HTTPChannel,2,127.0.0.1] 127.0.0.1 - - [06/Feb/2012:14:27:16 +0000] "POST /schedule.json HTTP/1.1" 200 62 "-" "python-requests/0.10.1"
2012-02-06 15:27:17+0100 [HTTPChannel,3,127.0.0.1] 127.0.0.1 - - [06/Feb/2012:14:27:16 +0000] "POST /schedule.json HTTP/1.1" 200 62 "-" "python-requests/0.10.1"
2012-02-06 15:27:18+0100 [Launcher] Process started: project='thz' spider='spider_1' job='abb6b62650ce11e19123c8bcc8cc6233' pid=2545
2012-02-06 15:27:19+0100 [Launcher] Process finished: project='thz' spider='spider_1' job='abb6b62650ce11e19123c8bcc8cc6233' pid=2545
2012-02-06 …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的项目:
my_project/
__init__.py -- empty
run.py
datacheck/
__init__.py -- empty
datacheck.py -- containing class DataCheck(object)
config.py -- containing BusinessConfig(object)
business.py -- containing class BusinessCheck(DataCheck)
Run Code Online (Sandbox Code Playgroud)
我PYTHONPATH的配置为/ my_project.
在run.py中,我有以下代码:
from datacheck.business import BusinessCheck
business = BusinessCheck()
business.check_data()
Run Code Online (Sandbox Code Playgroud)
在business.py中,我有以下导入失败:
from datacheck.config import BusinessConfig
from datacheck.datacheck import DataCheck
Run Code Online (Sandbox Code Playgroud)
像from .config import BusinessConfig作品一样的相对导入- 但是我已经在很多线程中读到绝对导入是首选.
为了做一个简单的测试,我还创建了以下内容:
myproject/
__init__.py -- empty
run_test.py
test/
__init__.py -- empty
test1.py -- containing class Test1(object)
test2.py -- containing class Test2(Test1)
Run Code Online (Sandbox Code Playgroud)
run_test.py导入并运行Test2该类,这并没有失败.
它让我有点大吃一惊,我不明白为什么我在datacheck中的绝对导入不起作用 - 谁能解释一下?
在我的url conf中,我有几个URL具有相同的命名参数user_id.是否可以在中间件中访问此参数 - 因此我可以将其一般性地传递给context_data - 或模板本身?
示例URL conf用于说明问题:
url(r'^b/(?P<user_id>[0-9]+)/edit?$', user.edit.EditUser.as_view(), name='user_edit'),
url(r'^b/(?P<user_id>[0-9]+)/delete?$', user.delete.DeleteUser.as_view(), name='user_delete')
Run Code Online (Sandbox Code Playgroud) 我正在尝试调试我遇到的一些Redis问题,并且有一些关于SET命令的不确定文档.
在我的Redis配置中; 我有以下几行(摘录):
# Note: with all the kind of policies, Redis will return an error on write
# operations, when there are not suitable keys for eviction.
#
# At the date of writing this commands are: set setnx setex append
Run Code Online (Sandbox Code Playgroud)
Status code reply: always OK since SET can't fail.
Run Code Online (Sandbox Code Playgroud)
对权威行为的任何见解?