[Ironpython-users] struct.pack(format, *args) not thread safe
Michael van der Kolff
mvanderkolff at gmail.com
Wed Jan 30 08:49:34 CET 2013
When using paramiko with more than one process spawning, I
occasionally get the following:
System.InvalidOperationException: The LinkedList node already belongs
to a LinkedList.
at System.Collections.Generic.LinkedList`1.ValidateNewNode(LinkedListNode`1
node) at System.Collections.Generic.LinkedList`1.AddFirst(LinkedListNode`1
node)
at IronPython.Modules.PythonStruct.pack(CodeContext context, String
fmt, Object[] values)
at CallSite.Target(Closure , CallSite , CodeContext , Object ,
String , Object )
at paramiko.message$37.add_int$491(PythonFunction $function, Object
self, Object n) in
C:\repo\trunk\external\python\paramiko\message.py:line 227
at paramiko.message$37.add_string$494(PythonFunction $function,
Object self, Object s) in
C:\repo\trunk\external\python\paramiko\message.py:line 259
at paramiko.transport$13.open_channel$273(PythonFunction $function,
Object self, Object kind, Object dest_addr, Object src_addr) in
C:\repo\trunk\external\python\paramiko\transport.py:line 773
... Lots more in the stack trace.
I think that this is due to PythonStruct.pack's usage of CacheDict,
which is explicitly marked as not thread safe. A quick and dirty hack
would be to force all users of _cache to lock it first, though I'm
sure there's a better answer.
Cheers,
Michael
More information about the Ironpython-users
mailing list