本文介绍了Django开发服务器重新加载需要太长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从升级到OSX Lion以来,这是我的问题:每当我在Django项目中更改文件时,runserver重新加载,需要相当长的时间才能再次开始服务。

This has been my problem since I've upgraded to OSX Lion: Whenever the runserver reloads when I change a file in my Django project, it takes quite a while before it starts serving again.

即使在新创建的Django 1.4项目中也会发生这种情况。在雪豹上没有这个问题。

This happens even in a newly created Django 1.4 project. Didn't have this problem though on Snow Leopard.

我使用cProfile,这是大部分时间花费的时间:

I used cProfile and this is where it spent most of its time:

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    1    0.001    0.001   48.068   48.068 manage.py:2(<module>)
    1    0.000    0.000   48.033   48.033 __init__.py:431(execute_manager)
    1    0.000    0.000   48.032   48.032 __init__.py:340(execute)
    1    0.000    0.000   47.908   47.908 base.py:182(run_from_argv)
    1    0.000    0.000   47.907   47.907 base.py:193(execute)
    1    0.000    0.000   47.814   47.814 runserver.py:39(handle)
    1    0.000    0.000   47.814   47.814 runserver.py:69(run)
    1    0.001    0.001   47.814   47.814 autoreload.py:129(main)
    1    0.000    0.000   47.813   47.813 autoreload.py:107(python_reloader)
    1    0.000    0.000   47.813   47.813 autoreload.py:96(restart_with_reloader)
    1    0.000    0.000   47.813   47.813 os.py:565(spawnve)
    1    0.000    0.000   47.813   47.813 os.py:529(_spawnvef)
    1   47.812   47.812   47.812   47.812 {posix.waitpid}
    ...

但我不明白为什么?

推荐答案

(对于仍然搜索答案的人)

(for guys still googling the answer)

我使用Vagrant Windows主机)。对于我来说,解决方案是从同步的 / vagrant 移动 virtualenv 文件夹。同步的文件夹的默认设置使用VirtualBox提供程序,这是问题。我们可以从的另一种同步方法中阅读: / p>

I had similar problem using Vagrant (on Windows host machine). Solution for me was move virtualenv folder away from synced /vagrant. Default settings of synced folders uses VirtualBox provider and that's the problem. We can read about this in another sync methods from Vagrant official documentation:

请参阅额外的信息。

这篇关于Django开发服务器重新加载需要太长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 20:00