Thanks! Given that useful multi-threaded hashing is only available because of IronPython's lack of GIL I can't complain too much :-) For reference, here is the issue link:<div><br></div><div><a href="http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20324">http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20324</a><br>
<div><br></div><div>I look forward to the fix in a future release.<div><br></div><div><div><div class="gmail_quote">On Sun, Jan 4, 2009 at 7:09 PM, Curt Hagenlocher <span dir="ltr"><<a href="mailto:curt@hagenlocher.org" target="_blank">curt@hagenlocher.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Not without looking at the source code...<br><br>We want to be at least as thread-safe as CPython, with the exception that we have no interest in implementing the equivalent of a "global interpreter lock" :). This particular case is just bad coding on our part. I can't promise you that there aren't other examples, but at least this one is pretty easy to fix.<div>
<div></div><div><br>
<br><div class="gmail_quote">On Sun, Jan 4, 2009 at 8:58 AM, Brian Merrell <span dir="ltr"><<a href="mailto:brian@merrells.org" target="_blank">brian@merrells.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Thanks Curt. I've filed a bug report. It makes me a bit nervous realizing that it isn't entirely transparent when shared memory/objects are being used. Normally I would think a local instance of hashlib.md5() would be thread-safe from other local instances. Is there any documentation of what other modules use global/static instances or other non-thread-safe implementations in IronPython?<div>
<div></div><div><br>
<br><div class="gmail_quote">On Tue, Dec 30, 2008 at 12:13 PM, Curt Hagenlocher <span dir="ltr"><<a href="mailto:curt@hagenlocher.org" target="_blank">curt@hagenlocher.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
I'm going to guess that this is because we use a static instance of MD5CryptoServiceProvider to do the hashing, something which may not be thread-safe. It looks like all of the IronPython crypto implementations do the same thing, so the SHA functions may have a similar issue.<div>
<br></div><div>Please file this as a bug on Codeplex.<br><br><div class="gmail_quote"><div><div></div><div>On Sat, Dec 20, 2008 at 1:56 PM, Brian Merrell <span dir="ltr"><<a href="mailto:brian@merrells.org" target="_blank">brian@merrells.org</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div><div></div><div><div><font size="2" face="Arial">I get the following error
periodically:</font></div>
<blockquote dir="ltr" style="margin-right:0px">
<div><font size="2" face="Arial">Exception in thread Thread-2:<br>Traceback (most
recent call last):<br> File "C:\Program Files\IronPython 2.0\Lib\threading.py",
line 486, in _Thread__bootstrap_inner<br> self.run()<br> File
"initial_ingest.py", line 33, in run<br> md5 =
hashlib.md5(contents).hexdigest()<br>SystemError: Hash not valid for use in
specified state.</font></div></blockquote>
<div dir="ltr"><font size="2" face="Arial">I am not sharing a md5() object between threads and have tried to avoid any shared memory issues:</font></div>
<div dir="ltr"><font size="2" face="Arial"></font> </div>
<blockquote dir="ltr" style="margin-right:0px">
<div dir="ltr"><font size="2" face="Arial">class Convert(threading.Thread):<br> def
__init__(self, queue):<br> threading.Thread.__init__(self)<br>
self.queue = queue<br> def run(self):<br> import hashlib<br>
while True:<br> abs_filename = self.queue.get()<br> f =
open(abs_filename, "rb")<br> contents = f.read()<br>
f.close()<br> md5 = hashlib.md5(contents).hexdigest()<br>
print md5, abs_filename<br>
self.queue.task_done()</font></div></blockquote>
<div dir="ltr"><font size="2" face="Arial">Any ideas why this is failing? Thanks,</font></div><div dir="ltr"><br></div><font color="#888888"><div dir="ltr">-brian</div>
</font><br></div></div>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br></div>
</div></div></div>