<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2">Another way is to modify monkey_patch() to monkey_patch(thread=False) in single process mode. (nova-scheduler is a single process<span> mode itself.)<br><br>Then u can debug it in pydev as usual.<br></span><br><br><font color="#990099">-----Rafael Durán Castañeda <a class="moz-txt-link-rfc2396E" href="mailto:rafadurancastaneda@gmail.com"><rafadurancastaneda@gmail.com></a> wrote: -----</font><div style="padding-left:5px;"><div style="padding-right:0px;padding-left:5px;border-left:solid black 2px;">To: <a class="moz-txt-link-abbreviated" href="mailto:openstack-dev@lists.openstack.org">openstack-dev@lists.openstack.org</a><br>From: Rafael Durán Castañeda <a class="moz-txt-link-rfc2396E" href="mailto:rafadurancastaneda@gmail.com"><rafadurancastaneda@gmail.com></a><br>Date: 08/22/2012 07:38PM<br>Subject: Re: [openstack-dev] Problem with debugging program   having eventlet.monkey_patch() code<br><br>        <!--Notes ACF <meta content="text/html; charset=ISO-8859-1"       http-equiv="Content-Type">-->           <div class="moz-cite-prefix">On 08/21/2012 03:49 PM,       <a class="moz-txt-link-abbreviated" href="mailto:michel.gauthier@bull.net">michel.gauthier@bull.net</a> wrote:<br>     </div>     <blockquote cite="mid:OF22039CE3.CCCA89B6-ONC1257A61.004A4033-C1257A61.004BE7D3@bull.net" type="cite"><font face="sans-serif" size="2">I have installed         winpdb, but I have still         a problem while debugging nova-scheduler service : </font>       <br>       <br>       <font face="sans-serif" size="2">on </font><tt><font face="Courier New,Courier,monospace" size="2">eventlet.monkey_patch()</font></tt><font face="sans-serif" size="2">         instruction, the debugger get the following exception :</font>       <br>       <br>       <br>       <font face="sans-serif" size="2">on winpdb GUI session ( launched         thru         : winpdb command and then atteched to the debugee session)</font>       <br>       <font face="sans-serif" size="2">Exception in thread Thread-57:</font>       <br>       <font face="sans-serif" size="2">Traceback (most recent call         last):</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/lib/python2.7/threading.py",         line 551, in __bootstrap_inner</font>       <br>       <font face="sans-serif" size="2">    self.run()</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/lib/python2.7/threading.py",         line 504, in run</font>       <br>       <font face="sans-serif" size="2">    self.__target(*self.__args,         **self.__kwargs)</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/local/lib/python2.7/dist-packages/rpdb2.py",         line 10790, in __event_monitor_proc</font>       <br>       <font face="sans-serif" size="2">    (n, sel) =         self.getSession().getProxy().wait_for_event(PING_TIMEOUT,         self.m_remote_event_index)</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/lib/python2.7/xmlrpclib.py",         line 1224, in __call__</font>       <br>       <font face="sans-serif" size="2">    return         self.__send(self.__name,         args)</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/local/lib/python2.7/dist-packages/rpdb2.py",         line 9520, in __request</font>       <br>       <font face="sans-serif" size="2">    raise _e</font>       <br>       <font face="sans-serif" size="2">RuntimeError: cannot release         un-acquired         lock</font>       <br>       <br>       <br>       <font face="sans-serif" size="2">on winpdb debugee session         (launched         thru : winpdb -d /usr/bin/nova-scheduler         --flagfile=/etc/nova/nova.conf         command)</font>       <br>       <font face="sans-serif" size="2">Exception in thread         __worker_target:</font>       <br>       <font face="sans-serif" size="2">Traceback (most recent call         last):</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/lib/python2.7/threading.py",         line 551, in __bootstrap_inner</font>       <br>       <font face="sans-serif" size="2">    self.run()</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/local/lib/python2.7/dist-packages/rpdb2.py",         line 4574, in run</font>       <br>       <font face="sans-serif" size="2">    threading.Thread.run(self)</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/lib/python2.7/threading.py",         line 504, in run</font>       <br>       <font face="sans-serif" size="2">    self.__target(*self.__args,         **self.__kwargs)</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/local/lib/python2.7/dist-packages/rpdb2.py",         line 9361, in __worker_target</font>       <br>       <font face="sans-serif" size="2">    self.m_lock.release()</font>       <br>       <font face="sans-serif" size="2">  File         "/usr/lib/python2.7/threading.py",         line 142, in release</font>       <br>       <font face="sans-serif" size="2">    raise RuntimeError("cannot         release un-acquired lock")</font>       <br>       <font face="sans-serif" size="2">RuntimeError: cannot release         un-acquired         lock</font>       <br>       <br>       <br>       <font face="sans-serif" size="2">Help for a solution.</font>       <br>       <br>       <br>       <br>       <br>       <br>       <font color="#5f5f5f" face="sans-serif" size="1">De :                </font><font face="sans-serif" size="1">Michael J Fork         <a class="moz-txt-link-rfc2396E" href="mailto:mjfork@us.ibm.com"><mjfork@us.ibm.com></a></font>       <br>       <font color="#5f5f5f" face="sans-serif" size="1">A :                </font><font face="sans-serif" size="1">OpenStack Development         Mailing List <a class="moz-txt-link-rfc2396E" href="mailto:openstack-dev@lists.openstack.org"><openstack-dev@lists.openstack.org></a></font>       <br>       <font color="#5f5f5f" face="sans-serif" size="1">Date :                </font><font face="sans-serif" size="1">17/08/2012 15:03</font>       <br>       <font color="#5f5f5f" face="sans-serif" size="1">Objet :                </font><font face="sans-serif" size="1">Re: [openstack-dev]         Problem with debugging program        having                eventlet.monkey_patch() code</font>       <br>       <hr noshade="noshade">       <br>       <br>       <br>       <font face="sans-serif" size="2">We have found that Winpdb (</font><a moz-do-not-send="true" href="http://winpdb.org/"><font color="blue" face="sans-serif" size="2"><u>http://winpdb.org/</u></font></a><font face="sans-serif" size="2">         - platform independent despite Win in the name) works well with         multi-threaded         Python.  While using PyDev for development, run Winpdb as a         remote         debugger for the multithreaded service.  Flow is like this:</font><font size="3"><br>       </font><font face="sans-serif" size="2"><br>         Launch Winpdb GUI<br>         # winpdb</font><font size="3"><br>       </font><font face="sans-serif" size="2"><br>         Start Debugging <br>         # cd /home/openstack-dev/workspace/nova/bin <br>         # winpdb -d -r <file_to_debug> <br>         Set Password: openstack </font><font size="3"><br>       </font><font face="sans-serif" size="2"><br>         Attach to Process<br>         1) In Winpdb GUI, select File -> Attach<br>         2) Enter password from step 4, should display files associated         with that         password <br>         3) Select process/file then select OK <br>          <br>         To Stop Debug or Make Changes and Restart <br>         1) File -> Stop to detach current debugger <br>         2) Make changes in Eclipse and Save (make sure development user         has write         privileges to repository) <br>         3) kill and restart winpdb debugging process started above<br>         4) Re-attach to the process in the Winpdb GUI<br>         <br>         Michael<br>         <br>         -------------------------------------------------<br>         Michael Fork<br>         Cloud Architect, Emerging Solutions<br>         IBM Systems & Technology Group</font><font size="3"><br>       </font><tt><font face="Courier New,Courier,monospace" size="2"><br>           <a class="moz-txt-link-abbreviated" href="mailto:michel.gauthier@bull.net">michel.gauthier@bull.net</a> wrote on 08/17/2012 07:59:18 AM:<br>           <br>           > From: <a class="moz-txt-link-abbreviated" href="mailto:michel.gauthier@bull.net">michel.gauthier@bull.net</a><br>           > To: <a class="moz-txt-link-abbreviated" href="mailto:openstack-dev@lists.openstack.org">openstack-dev@lists.openstack.org</a>, <br>           > Date: 08/17/2012 08:02 AM<br>           > Subject: [openstack-dev] Problem with debugging program           having <br>           > eventlet.monkey_patch() code<br>           > <br>           > Hi all, <br>           > I want to debug nova-scheduler service (Essex version)            code           with <br>           > Eclipse->Pydev->Debug Configuration. <br>           > But when I launch it under Debug Configuration, I get the           following           <br>           > error messages : <br>           > <br>           > pydev debugger: starting <br>           > Traceback (most recent call last): <br>           >   File           "/usr/lib/python2.7/dist-packages/eventlet/hubs/hub.py",           line<br>           > 336, in fire_timers <br>           >     timer() <br>           >   File           "/usr/lib/python2.7/dist-packages/eventlet/hubs/timer.py",           <br>           > line 56, in __call__ <br>           >     cb(*args, **kw) <br>           >   File           "/usr/lib/python2.7/dist-packages/eventlet/semaphore.py",           <br>           > line 95, in _do_acquire <br>           >     waiter.switch() <br>           > error: cannot switch to a different thread <br>           > <br>           > and then, Pydev debugger does not work! <br>           > <br>           > In fact, these errors are due to the use of           eventlet.monkey_patch()           inside <br>           > nova-scheduler launcher (as well as inside other nova-*           launchers).           <br>           > <br>           > Do you have any ideas to resolve this problem? <br>           > <br>           > Thanks in           advance._______________________________________________<br>           > OpenStack-dev mailing list<br>           > <a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>           > </font></tt><a moz-do-not-send="true" href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev"><tt><font color="blue" face="Courier New,Courier,monospace" size="2"><u>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</u></font></tt></a><tt><font face="Courier New,Courier,monospace" size="2">_______________________________________________<br>           OpenStack-dev mailing list<br>           <a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>         </font></tt><a moz-do-not-send="true" href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev"><tt><font face="Courier New,Courier,monospace" size="2">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</font></tt></a><tt><font face="Courier New,Courier,monospace" size="2"><br>         </font></tt>       <br>       <br>       <fieldset class="mimeAttachmentHeader"></fieldset>       <br>       <div><font face="Courier New,Courier,monospace" size="2">_______________________________________________<br>OpenStack-dev mailing list<br><a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br><a class="moz-txt-link-freetext" href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br></font></div>     </blockquote>     As a quick workaround you can change monkey patching at     nova-scheduler script:<br>     <br>      eventlet.monkey_patch(thread=False)<br>     <br>     HTH<br>    <div><font face="Courier New,Courier,monospace" size="2">_______________________________________________<br>OpenStack-dev mailing list<br><a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br></font></div></div></div></font>