<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Thank you, I'll take your advice.</p>
<p>Regarding your example, I think it gives the illusion to work
because sleep() is GIL aware under the hood.</p>
<p>I don't think it works for process() that mainly runs bytecode,
because of the GIL.</p>
<p>Sorry if I wrongly thought that was a language level discussion.<br>
</p>
<p>Regards,</p>
<p>Matthieu<br>
</p>
<br>
<div class="moz-cite-prefix">On 9/13/17 10:49 AM, Chris Barker
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CALGmxEJiGhQdsrGVgxV3nAL8mJGMaCMaqcJ174PEiyUD1+Yd6A@mail.gmail.com">
<div dir="ltr">This really isn't the place to ask this kind of
question.
<div><br>
</div>
<div>If you want to know how to do something with python, try
python-users , stack overflow, etc.</div>
<div><br>
</div>
<div>If you have an idea about a new feature you think python
could have, then the python-ideas list is the place for that.
But if you want anyone to take it seriously, it should be a
better formed idea before you post there.</div>
<div><br>
</div>
<div>But:</div>
<div><br>
</div>
<div class="gmail_extra">
<div class="gmail_quote">On Tue, Sep 12, 2017 at 4:43 PM,
Matthieu Bec <span dir="ltr"><<a
href="mailto:mdcb808@gmail.com" target="_blank"
moz-do-not-send="true">mdcb808@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">There are times when
you deal with completely independent input/output 'pipes'
- where parallelizing would really help speed things up.<br>
<br>
Can't there be a way to capture that idiom and multi
thread it in the language itself?<br>
<br>
Example:<br>
<br>
loop:<br>
<br>
read an XML<br>
<br>
produce a JSON like<br>
</blockquote>
<div><br>
</div>
<div>Regular old threading works fine for this:</div>
<div><br>
</div>
<font face="monospace, monospace">import time<br>
import random<br>
import threading<br>
<br>
<br>
def process(infile, outfile):<br>
"fake function to simulate a process that takes a
random amount of time"<br>
time.sleep(random.random())<br>
print("processing: {} to make {}".format(infile,
outfile))<br>
<br>
<br>
for i in range(10):<br>
threading.Thread(target=process, args=("file%i.xml" %
i, "file%i.xml" % i)).start()<br>
</font>
<div><br>
</div>
<div><br>
</div>
<div>It gets complicated if you need to pass information
back and forth, or worry about race conditions, or manage
a queue, or ....</div>
<div><br>
</div>
<div>But just running a nice self-contained thread safe
function in another thread is pretty straightforward.</div>
<div><br>
</div>
<div>-CHB</div>
<div><br>
</div>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature"><br>
Christopher Barker, Ph.D.<br>
Oceanographer<br>
<br>
Emergency Response Division<br>
NOAA/NOS/OR&R (206) 526-6959 voice<br>
7600 Sand Point Way NE (206) 526-6329 fax<br>
Seattle, WA 98115 (206) 526-6317 main reception<br>
<br>
<a href="mailto:Chris.Barker@noaa.gov" target="_blank"
moz-do-not-send="true">Chris.Barker@noaa.gov</a></div>
</div>
</div>
</blockquote>
<br>
</body>
</html>