我最近升级到python2.7和django1.3,从那时起
Unhandled exception in thread started by <bound method Command.inner_run of <django.core.management.commands.runserver.Command object at 0x109c57490>>
Traceback (most recent call last):
File "/Users/ApPeL/.virtualenvs/myhunt/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 88, in inner_run
self.validate(display_num_errors=True)
File "/Users/ApPeL/.virtualenvs/myhunt/lib/python2.7/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/Users/ApPeL/.virtualenvs/myhunt/lib/python2.7/site-packages/django/core/management/validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Users/ApPeL/.virtualenvs/myhunt/lib/python2.7/site-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/Users/ApPeL/.virtualenvs/myhunt/lib/python2.7/site-packages/django/db/models/loading.py", line 67, in _populate
self.write_lock.release()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 137, in release
raise RuntimeError("cannot release un-acquired lock")
RuntimeError: cannot release un-acquired lock
非常感谢您的帮助。
答案 0 :(得分:1)
通常的第一个建议是将最新更新应用于gevent或greenlet或您使用的与线程相关的内容。在Python 2.6和2.7之间改变了threading.Thread.start的实现。有很多食谱如何用Django开始绿色......或绿色......尝试阅读Python 2.7的最新版本。并发送一个问题的链接。
<强>调试:强>
将以下行添加到manage.py
以启用将线程启动等记录到stderr:
import threading
setattr(threading, '__debug__', True)
将参数verbose
添加到{39}行{39},以便查看线程获取并释放锁定。
django/db/loading.py
运行开发服务器。对于没有自动重载的一个线程,你应该看到类似的东西:
- write_lock = threading.RLock(),
+ write_lock = threading.RLock(verbose=True),
注意:
$ python manage.py runserver --noreload
Validating models...
MainThread: <_RLock owner='MainThread' count=1>.acquire(1): initial success
MainThread: <_RLock owner=None count=0>.release(): final release
- 第一次通过阻挡锁获取
count=1 acquire(1)
- 锁目前正在解锁
owner=None count=0>.release()
这与autoreload相同。模型由子进程验证。 “Dummy-1”是线程的符号名称。这可以针对更多线程重复,但是在前一个线程释放之前,没有线程应该/可以获取锁。我们可以继续根据结果。