<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [ISSUE} YDK-PY CRUD service with Python flask microframework in Tools</title>
    <link>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4184549#M1701</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody have an idea about this? we have the totally same issue with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The crudService.read ran well when we use single python script, but got stuck when it in the flask framework which as a http service.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help me, thanks very much.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2020 06:56:37 GMT</pubDate>
    <dc:creator>ElvisLou15831</dc:creator>
    <dc:date>2020-11-17T06:56:37Z</dc:date>
    <item>
      <title>[ISSUE} YDK-PY CRUD service with Python flask microframework</title>
      <link>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/3849202#M1699</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like some guidance on a script that gets operational data from xr router, then certain key/values are extracted from the json output, with the goal to display it on a webpage (using YDK-PY with FLASK microframework to display data on to the webpage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I call the flask app.router(/interfaceStats) decorater, my script seems to hang at the CRUD operation.&amp;nbsp; During the crud -&lt;/P&gt;
&lt;P&gt;intPropObj1=crud.read(provider, intPropObj)&lt;/P&gt;
&lt;P&gt;the script hangs, and so does the flask web server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;RK&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code Snippet -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/528221"&gt;@app&lt;/a&gt;.route(&lt;/SPAN&gt;'/interfaceStats'&lt;SPAN class="s1"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="s2"&gt;def&lt;/SPAN&gt; interfaceStats():&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;_init_logging()&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;dir_path = os.path.dirname(os.path.realpath(__file__))&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;private = &lt;SPAN class="s3"&gt;"%s/id_rsa"&lt;/SPAN&gt; % dir_path&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;public = &lt;SPAN class="s3"&gt;"%s/id_rsa.pub"&lt;/SPAN&gt; % dir_path&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;print&lt;/SPAN&gt;(dir_path, private, public)&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;provider = NetconfServiceProvider(address=&lt;SPAN class="s4"&gt;'192.168.253.144'&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;username=&lt;SPAN class="s4"&gt;'rkotwani'&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;protocol=&lt;SPAN class="s4"&gt;'ssh'&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;timeout=&lt;SPAN class="s4"&gt;0&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;port=&lt;SPAN class="s4"&gt;22&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;private_key_path=private,&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;public_key_path=public)&lt;/P&gt;
&lt;P class="p3"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;codec = CodecService()&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;provider1 = CodecServiceProvider(type=&lt;SPAN class="s3"&gt;"json"&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;print&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;(&lt;/SPAN&gt;"past codec provider1"&lt;SPAN class="s1"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;crud = CRUDService()&lt;/P&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;print&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;(&lt;/SPAN&gt;"past crud instantiation"&lt;SPAN class="s1"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;intPropObj=ifmgr_oper.InterfaceProperties()&lt;/P&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;print&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;(&lt;/SPAN&gt;"here"&lt;SPAN class="s1"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s1"&gt;# Getting stuck below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;intPropObj1=crud.read(provider, intPropObj)&lt;/P&gt;
&lt;P class="p5"&gt;# Getting stuck at the above line&lt;/P&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;print&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;(&lt;/SPAN&gt;"here 2"&lt;SPAN class="s1"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;jsonIntPropObj = codec.encode(provider1, intPropObj1)&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;print&lt;/SPAN&gt;(jsonIntPropObj)&lt;/P&gt;
&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;return&lt;/SPAN&gt; render_template(&lt;SPAN class="s4"&gt;'index.html'&lt;/SPAN&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 15:41:48 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/3849202#M1699</guid>
      <dc:creator>rkotwani@cisco.com</dc:creator>
      <dc:date>2019-05-02T15:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: [ISSUE} YDK-PY CRUD service with Python flask microframework</title>
      <link>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/3865492#M1700</link>
      <description>&lt;P&gt;were you able to sort out the problem?&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 22:56:43 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/3865492#M1700</guid>
      <dc:creator>saalvare</dc:creator>
      <dc:date>2019-05-30T22:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: [ISSUE} YDK-PY CRUD service with Python flask microframework</title>
      <link>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4184549#M1701</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody have an idea about this? we have the totally same issue with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The crudService.read ran well when we use single python script, but got stuck when it in the flask framework which as a http service.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help me, thanks very much.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 06:56:37 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4184549#M1701</guid>
      <dc:creator>ElvisLou15831</dc:creator>
      <dc:date>2020-11-17T06:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: [ISSUE} YDK-PY CRUD service with Python flask microframework</title>
      <link>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4184841#M1702</link>
      <description>&lt;P&gt;Hello Elvis Lou&lt;/P&gt;&lt;P&gt;In my opinion you are facing known and documented &lt;A href="https://github.com/CiscoDevNet/ydk-gen/issues/825" target="_self"&gt;issue&lt;/A&gt;, which is related to multithreading. I believe the flask operator, spawns new thread, which interrupts thread with YDK related process. As a workaround you have to refactor structure of your script in a way that WHOLE YDK related operation is inclosed in one thread from start to finish.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 18:10:50 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4184841#M1702</guid>
      <dc:creator>yangorelik</dc:creator>
      <dc:date>2020-11-17T18:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: [ISSUE} YDK-PY CRUD service with Python flask microframework</title>
      <link>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4184994#M1703</link>
      <description>&lt;P&gt;Thanks for the reply, yangorelik,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so it is not possible that run ydk api call concurrently in one process?&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it must ran&amp;nbsp;&lt;SPAN&gt;Serializable for any operation to cisco router?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 00:23:25 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4184994#M1703</guid>
      <dc:creator>ElvisLou15831</dc:creator>
      <dc:date>2020-11-18T00:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: [ISSUE} YDK-PY CRUD service with Python flask microframework</title>
      <link>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4185434#M1704</link>
      <description>&lt;P&gt;You can have multiple threads in one process, but when it comes to execution of YDK involved operation, the last must be located in single thread.&lt;/P&gt;&lt;P&gt;The issue&amp;nbsp;&lt;A href="https://github.com/CiscoDevNet/ydk-gen/issues/825" target="_self"&gt;#825&lt;/A&gt;&amp;nbsp; has nothing to do with serialization, it comes from YDK design/implementation. Keep in mind that all actual operations on data is happening in C++ code, which is connected to Python code via Pybind11 adapter. When Python code sends request to C++ code the adapter locks the python thread in order to get reliably the response.&lt;/P&gt;&lt;P&gt;In your script example you import YDK related modules and initiate logger in main thread. The Flask call creates another thread to execute&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;interfaceStats()&lt;/EM&gt; function. That action confuses&amp;nbsp;Pybind11 adapter and eventually causes the YDK thread to get stalled.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 18:33:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/issue-ydk-py-crud-service-with-python-flask-microframework/m-p/4185434#M1704</guid>
      <dc:creator>yangorelik</dc:creator>
      <dc:date>2020-11-18T18:33:06Z</dc:date>
    </item>
  </channel>
</rss>

