<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 19, 2013 at 12:28 PM, Daniel Narvaez <span dir="ltr"><<a href="mailto:dwnarvaez@gmail.com" target="_blank">dwnarvaez@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Can you explain where multi thread would be an issue in our code? Why I'm thinking perhaps simplistically is that we are already dealing with the window.sugar stuff being available asyncronously.</blockquote>
</div></div><div class="gmail_extra">Yes, we dealt with this, already. But I didn't know that some browser may run frames simultaneously.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Suppose the following scenario:</div>
<div class="gmail_extra">* order of execution is not guaranteed</div><div class="gmail_extra">* javascript from python runs on top frame</div><div class="gmail_extra">* env.js runs on an iframe</div><div class="gmail_extra">
* different frames may run simultneously</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">js from python:</div><div class="gmail_extra"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">var environment = %s; <--- phase 1</font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">if (window.sugar === undefined) {<br></font><font face="courier new, monospace"> </font><span style="font-family:'courier new',monospace">window.sugar = {};<br></span><span style="font-family:'courier new',monospace">}</span><span style="font-family:'courier new',monospace"><br>
</span><span style="font-family:'courier new',monospace">window.sugar.environment = environment; </span><span style="font-family:'courier new',monospace"><--- phase 2</span></blockquote><div><br></div>
</div></div><div class="gmail_extra">from getEnvironment:</div><div class="gmail_extra"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">if (window.top.sugar) {</font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace"> sugar = window.top.sugar;<br></font><font face="courier new, monospace">} else {</font><font face="courier new, monospace"><br></font><font face="courier new, monospace"> sugar = {}; </font><span style="font-family:'courier new',monospace"><--- phase 1</span><font face="courier new, monospace"><br>
</font><font face="courier new, monospace"> window.top.sugar = sugar; </font><span style="font-family:'courier new',monospace"><--- phase 2</span><font face="courier new, monospace"><br></font><font face="courier new, monospace">}</font></blockquote>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">In this case, they would be running for<font face="courier new, monospace"> window.top.sugar</font> and it may result with <font face="courier new, monospace">{}</font></div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Our scenario is running "js from python" far earlier than getEnvironment (but not guaranteed), therefore, even with multithreading, this is unlikely to happen.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">I just a thought, but I would like to hear what do you think</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>