2012-02-07 7 views
3

私はWindowsでPyramid開発を始めました。私はPython 2.7をインストールしました。私はvirtualenvを使って、私のPyramidアプリケーション用の素敵なサンドボックスを作りました。 Eclipse IndigoでPyDev 2.4を作成しました。私はまた、私のvirutalenv専用のPyDevインタプリタを作成したので、すべてのディレクトリにアクセスする必要があります。Eclipseを使用してpserveをデバッグする方法はありますか?

私は新しいデバッグ構成を設定しました。

  • プロジェクト:testappと(ワークスペース内のみプロジェクト)
  • メインモジュール:$ {workspace_loc:testappと/スクリプト/ pserve-script.py}
  • Argsの:開発。のini
  • 作業ディレクトリ:その他:$ {workspace_loc:testappと/ testappと}

Iが出力され、デバッグを打つ:

pydev debugger: starting Starting server in PID 2208.
Unhandled exception in thread started by
Traceback (most recent call last):
File "C:\Tools\eclipse-cpp-indigo-SR1-incubation-win32-x86_64\eclipse\plugins\org.python.pydev.debug_2.3.0.2011121518\pysrc\pydevd.py", line 200, in __call__ Unhandled exception in thread started by
Traceback (most recent call last):
Unhandled exception in thread started by
Traceback (most recent call last):
File "C:\Tools\eclipse-cpp-indigo-SR1-incubation-win32-x86_64\eclipse\plugins\org.python.pydev.debug_2.3.0.2011121518\pysrc\pydevd.py", line 200, in __call__ self.original_func(*self.args, **self.kwargs)
Unhandled exception in thread started by
File "C:\Tools\eclipse-cpp-indigo-SR1-incubation-win32-x86_64\eclipse\plugins\org.python.pydev.debug_2.3.0.2011121518\pysrc\pydevd.py", line 200, in __call__
TypeErrorTraceback (most recent call last):
self.original_func(*self.args, **self.kwargs) :
File "C:\Tools\eclipse-cpp-indigo-SR1-incubation-win32-x86_64\eclipse\plugins\org.python.pydev.debug_2.3.0.2011121518\pysrc\pydevd.py", line 200, in __call__ self.original_func(*self.args, **self.kwargs)
TypeErrorThreadedTaskDispatcher object argument after ** must be a mapping, not tuple
TypeError: self.original_func(*self.args, **self.kwargs) : ThreadedTaskDispatcher object argument after ** must be a mapping, not tuple
TypeErrorThreadedTaskDispatcher object argument after ** must be a mapping, not tuple :
ThreadedTaskDispatcher object argument after ** must be a mapping, not tuple
serving on http://0.0.0.0:6543

それは、サーバが実行されていると言うにもかかわらず、それはありません。そのポートでリッスンしているものはありません。

これを修正する方法はありますか?デバッグは必ずしも必要ではありませんが、私は完全にセットアップされた開発環境が好きです。ありがとう!

+0

私はPyDev 2.4をインストールしていないことを実感しました。 2.4にアップグレードしても、同じエラーが表示されます。 – jmacdonagh

答えて

0

このエラーは発生しませんでしたが、通常、デバッグ環境が難しい場合は、リモートデバッガ(http://pydev.org/manual_adv_remote_debugger.html)を使用することができます(pdbのように動作します:ブレークポイントを追加するコードを追加してください。その時点まで、プログラムは通常どおり実行されます)。

+0

返事をありがとう。私はこれらのステップを踏んで、私のPyramidアプリケーションの '__init __。py'で' pydevd.settrace() '呼び出しを追加しました。以下の手順を実行すると、Eclipse *は 'pydevd.settrace()'の呼び出しの直後に '__init __。py'に侵入します。しかし、私はviews.pyで唯一のビューにブレークポイントを設定してヒットしますが、そのブレークポイントは決してヒットしません(もちろん、ブラウザを再表示してビュールーチンを再度実行しようとしました)。ブレークポイントウィンドウは 'views.py'ブレークポイントがアクティブであることを示していますので、何が起こっているのか分かりません。 – jmacdonagh

+0

要求に対して別のプロセスを生成しているかどうかを知っていますか(その場合、各プロセスでpydevd.settraceを再度呼び出さなければなりません)... –

2

ピラミッドには、debug toolbarの形式で非常に優れたデバッグサポートが含まれています。

はラインあなたのdevelopment.ini

pyramid.includes = pyramid_debugtoolbar 

が、それを可能にするために、コメントアウトされていないことを確認します。それはEclipseのブレークポイントをサポートしていませんが、あなたが望むほとんどすべてのものを提供します。

0

Pythonのpserveは、Fabioのように複数のスレッドを使用しているようです。

set_trace(..., trace_only_current_thread=False) 

しかし、これはアプリがunusably遅くなり、あるいはしないか:私も試した

# Allow attaching PyDev to the web app 
import sys;sys.path.append('..../pydev/2.5.0-2/plugins/org.python.pydev.debug_2.4.0.201208051101/pysrc/') 

# Monkey patch the thread task dispatcher, so it sets up the tracer in the worker threads 
from waitress.task import ThreadedTaskDispatcher 
_prev_start_new_thread = ThreadedTaskDispatcher.start_new_thread 
def start_new_thread(ttd, fn, args): 
    def settrace_and_call(*args, **kwargs): 
     import pydevd ; pydevd.settrace(suspend=False) 
     return fn(*args, **kwargs) 
    from thread import start_new_thread 
    start_new_thread(settrace_and_call, args) 
ThreadedTaskDispatcher.start_new_thread = start_new_thread 

注:私は、ブレークポイントがpserveを起動する前に、猿パッチングThreadTaskDispatcherで動作させることができました何か他の理由のために働く。

これを実行すると、アプリケーションは自動的にローカルで実行されているpydevデバッグサーバーに自動的に登録されます。参照してください: http://pydev.org/manual_adv_remote_debugger.html

関連する問題