[Python-bugs-list] [Bug #128475] mimetools.encode (sometimes) fails when called from a thread
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 15 Jan 2001 11:54:47 -0800
Bug #128475, was updated on 2001-Jan-11 11:05
Here is a current snapshot of the bug.
Project: Python
Category: Threads
Status: Open
Resolution: None
Bug Group: Platform-specific
Priority: 5
Submitted by: nobody
Assigned to : tim_one
Summary: mimetools.encode (sometimes) fails when called from a thread
Details: I used this script to test. The code of filesender.prepare_msgs
is at the end of the report.
##
import threading
import filesender
file = open('c:/windows/desktop/mp3/Aphex Twin - Bucephalus Bouncing
Ball.mp3', 'rb')
t1 = threading.Thread(target=filesender.prepare_msgs, args=(file,'a@b.c'))
from cStringIO import StringIO
data = StringIO()
import mimetools
t2=threading.Thread(target=mimetools.encode, args=(file,data,'base64'))
import sys
if '-t1' in sys.argv:
t1.start()
elif '-t2' in sys.argv:
t2.start()
else:
filesender.prepare_msgs(file, 'a@b.c')
##
Results of running it with -t1, -t2, and no options, on Windows:
C:\Python20>python test.py -t1
preparing Aphex Twin - Bucephalus Bouncing Ball.mp3
Fatal Python error: Interpreter not initialized (version mismatch?)
abnormal program termination
C:\Python20>python test.py -t1
preparing Aphex Twin - Bucephalus Bouncing Ball.mp3
Fatal Python error: Interpreter not initialized (version mismatch?)
abnormal program termination
C:\Python20>python test.py -t2
Fatal Python error: Interpreter not initialized (version mismatch?)
abnormal program termination
C:\Python20>python test.py -t2
C:\Python20>python test.py
preparing Aphex Twin - Bucephalus Bouncing Ball.mp3
encoded
got value
data length is 7807732
Encoded Aphex Twin - Bucephalus Bouncing Ball.mp3 is too large, splitting
into 2
parts
C:\Python20>python test.py
preparing Aphex Twin - Bucephalus Bouncing Ball.mp3
encoded
got value
data length is 7807732
Encoded Aphex Twin - Bucephalus Bouncing Ball.mp3 is too large, splitting
into 2
parts
On Linux:
wolfson@senator:~% python test.py
preparing Aphex Twin - Bucephalus Bouncing Ball.mp3
encoded
got value
data length is 7807732
Encoded Aphex Twin - Bucephalus Bouncing Ball.mp3 is too large, splitting
into 2 p
arts
wolfson@senator:~% python test.py -t1
preparing Aphex Twin - Bucephalus Bouncing Ball.mp3
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort
wolfson@senator:~% python test.py -t1
preparing Aphex Twin - Bucephalus Bouncing Ball.mp3
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort
wolfson@senator:~% python test.py -t2
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort
wolfson@senator:~% python test.py -t2
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort
wolfson@senator:~% python test.py -t2
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort
On Sun 5 it seems to always succeed.
The code for filesender.prepare_msgs:
def prepare_msgs(file, addressee):
data = StringIO.StringIO()
fn = getname(file)
print 'preparing %s' % fn
mimetools.encode(file, data, 'base64')
print 'encoded'
data = data.getvalue()
print 'got value'
datalen = len(data)
print 'data length is %d' % datalen
if datalen > MAX_MSG_SZ:
numsplits = 1 + datalen / MAX_MSG_SZ
print 'Encoded %s is too large, splitting into %d parts' %
(fn,numsplits)
msgs = []
for i in range(numsplits):
thismsg, data = data[:MAX_MSG_SZ], data[MAX_MSG_SZ:]
msgs.append(fmt_message(fn, addressee,
thismsg,
'(%d/%d)' % (i+1, numsplits), MSG))
return msgs
return [fmt_message(fn, addressee, data, '', MSG)]
Follow-Ups:
Date: 2001-Jan-15 11:54
By: gvanrossum
Comment:
I'm assigning this to Tim, our all-purpose Windows cleaner. :-)
Thread problems like this are notoriously hard to find, so don't hold your
breath. Sorry!
Setting the group to platform-specific since you mention it works fine on
Sun5.
-------------------------------------------------------
Date: 2001-Jan-13 08:13
By: nobody
Comment:
I'll get you!
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=128475&group_id=5470