Pycharm Django调试真的很慢 [英] Pycharm Django Debugging is really slow

查看:3052
本文介绍了Pycharm Django调试真的很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个中等大小的网站,但PyCharm需要大约30秒才能启动Runserver,并准备好运行应用程序。如果我运行应用程序而不是调试,则只需要大约3秒钟才能启动。



我可以做些什么加快代码更改和调试周期。
我正在使用一个体面的MBP与16Gb的RAM。所以硬件不是问题。



我从项目中排除了/媒体文件。
我没有任何其他大量的文件将导致索引问题
我正在使用Postgres和Mongo数据库。
我正在运行Django 1.7 +十几个包,如:

  dj-static == 0.0.6 
django-annoying == 0.8.1
django-appconf == 1.0.1
django-bootstrap-form == 3.2
django-bootstrap-pagination == 1.5.1
django-compressor == 1.5
django-extensions == 1.5.5
django-filter == 0.10.0
django-guardian == 1.2.5
django-存储减少== 1.2.3
django-widget-tweaks == 1.3
djangorestframework == 3.1.2
django-jinja == 1.4.1

这是调试输出:

  /Users/user1/.virtualenvs/env-test/bin/python/ Applications / PyCharm 4.5 EAP.app/Contents/helpers/pydev/pydevd.py--multiproc --save-signatures --client 127.0.0.1  - -port 64097 --file /Users/user1/gitroot/website1/manage.py runserver 0.0.0.0:8000 --verbosity 2 
连接到pydev调试器(build 141.1245)
pydev调试器:进程63926是连接

pydev调试器:进程63954正在连接

执行系统检查...

系统检查已识别无问题(0沉默)。
您有未应用的迁移;您的应用程序在应用之前可能无法正常工作。
运行'python manage.py migrate'来应用它们。
2015年6月3日 - 09:08:52
Django版本1.7.7,使用设置'myproject.settings'
启动开发服务器在http://0.0.0.0:8000/
使用CONTROL-C退出服务器。

更新:
由于这篇文章Pycharm有能力使用Cython作为解释器。我觉得有些改善了。我也转移到使用Runserverplus,我认为运行速度更快。

解决方案

嗯,调试器的速度很慢,你可以做的不多。只要不要使用调试器,除非你绝对需要它(例如,你正在排除一个特别难以捉摸的错误)。



我可以想到只有一件事可能会加速PyCharm的调试器,那就是关闭收集运行时类型信息以获取代码洞察设置(位于文件>设置>构建,执行,部署> Python调试器下)。


I have a moderate size website but it takes about 30 seconds for PyCharm to start Runserver and be ready to run the app. If I "Run" the app instead of "Debugging" it will only take about 3 seconds to start.

What are some of the things I can do speed up the code change and debugging cycle. I am using a decent MBP with 16Gb of RAM. So hardware is not the issue.

I have excluded /media files from the project. I don't any other large number of files that will cause indexing problems I am using both Postgres and Mongo db. I am running Django 1.7 + a dozen of packages like:

dj-static==0.0.6
django-annoying==0.8.1
django-appconf==1.0.1
django-bootstrap-form==3.2
django-bootstrap-pagination==1.5.1
django-compressor==1.5
django-extensions==1.5.5
django-filter==0.10.0                              
django-guardian==1.2.5
django-storages-redux==1.2.3
django-widget-tweaks==1.3
djangorestframework==3.1.2                        
django-jinja==1.4.1

This is debug output:

/Users/user1/.virtualenvs/env-test/bin/python "/Applications/PyCharm 4.5 EAP.app/Contents/helpers/pydev/pydevd.py" --multiproc --save-signatures --client 127.0.0.1 --port 64097 --file /Users/user1/gitroot/website1/manage.py runserver 0.0.0.0:8000 --verbosity 2
Connected to pydev debugger (build 141.1245)
pydev debugger: process 63926 is connecting

pydev debugger: process 63954 is connecting

Performing system checks...

System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
June 03, 2015 - 09:08:52
Django version 1.7.7, using settings 'myproject.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.

UPDATE: Since this post Pycharm has the ability to use Cython as the interpreter. I think that has improved things somewhat. I also moved to use Runserverplus which I think runs faster.

解决方案

Well, the debugger is just slow and there is not much you can do about it. Just don't use the debugger unless you absolutely need it (i.e. you are troubleshooting a particularly elusive bug).

I can think of only one thing that may speed up the PyCharm's debugger and that is to turn off the "Collect run-time types information for code insight" setting (located under File > Settings > Build, Execution, Deployment > Python Debugger).

这篇关于Pycharm Django调试真的很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆