From a10f7ed26b4275059ccddf15491893656c0f661b Mon Sep 17 00:00:00 2001
From: "SND\\kernelnet_cp"
 <SND\kernelnet_cp@9b283d60-5439-405e-af05-b73fd8c4d996>
Date: Fri, 29 Mar 2013 11:32:30 +0000
Subject: [PATCH] [0.2.x] fixed : !pycmd falled to loop

git-svn-id: https://pykd.svn.codeplex.com/svn@83134 9b283d60-5439-405e-af05-b73fd8c4d996
---
 pykd/win/dbgeng.cpp | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp
index 696f6fd..75abc5c 100644
--- a/pykd/win/dbgeng.cpp
+++ b/pykd/win/dbgeng.cpp
@@ -4,6 +4,7 @@
 
 #include "win/dbgeng.h"
 #include "win/dbgio.h"
+#include "win/windbg.h"
 #include "dbgexcept.h"
 #include "eventhandler.h"
 #include "symengine.h"
@@ -1309,15 +1310,18 @@ DebugEngine::DbgEngBind* DebugEngine::operator->()
 
     m_bind.reset(new DbgEngBind(client, this) );
 
-    python::object   main = boost::python::import("__main__");
+    if ( !WindbgGlobalSession::isInit() )
+    {
+        python::object   main = boost::python::import("__main__");
 
-    python::object   main_namespace = main.attr("__dict__");
+        python::object   main_namespace = main.attr("__dict__");
 
-    python::object   pykd = boost::python::import( "pykd" );
+        python::object   pykd = boost::python::import( "pykd" );
 
-    main_namespace["globalEventHandler"] = EventHandlerPtr( new EventHandlerImpl() );
+        main_namespace["globalEventHandler"] = EventHandlerPtr( new EventHandlerImpl() );
 
-    client->SetInputCallbacks( this );
+        client->SetInputCallbacks( this );
+    }
 
     return m_bind.get();
 }