[issue10923] Python 2.7 hangs on Unicode+threading

2011-01-19 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

 import child_directory
Then it's certainly an effect of the import lock:
http://docs.python.org/library/threading.html#importing-in-threaded-code

In your case, the first call to encode('utf8') indirectly imports utf8.py, 
while the import lock is held by 'import child_directory'.
Then the self.loglock is the second resource that closes the deadlock loop.

A workaround is to add some call to encode('utf8') before the thread is created.

--
nosy: +amaury.forgeotdarc
resolution:  - works for me

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10923
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10923] Python 2.7 hangs on Unicode+threading

2011-01-19 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
nosy: +brett.cannon

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10923
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10923] Python 2.7 hangs on Unicode+threading

2011-01-18 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10923
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10923] Python 2.7 hangs on Unicode+threading

2011-01-17 Thread Brian Curtin

Changes by Brian Curtin cur...@acm.org:


--
type: crash - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10923
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10923] Python 2.7 hangs on Unicode+threading

2011-01-17 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Please attach a simple script reproducing the perceived problem.

--
components: +Library (Lib) -None
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10923
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10923] Python 2.7 hangs on Unicode+threading

2011-01-17 Thread Piotr Maślanka

Piotr Maślanka piotr.masla...@henrietta.com.pl added the comment:

I ripped some stuff from the project I'm working on, undependencing it on any 
my libraries.

Can someone with similar conf(Win7 x86-64, Python 2.7.1 (r271:86832, Nov 27 
2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32) confirm this?

Directory configuration when I run that script was that it was in a child 
directory and was invoked by a script with import child_directory.

Before you say 'can't reproduce', run it at least 15 times, please.

--
Added file: http://bugs.python.org/file20429/start.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10923
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10923] Python 2.7 hangs on Unicode+threading

2011-01-16 Thread Piotr Maślanka

New submission from Piotr Maślanka piotr.masla...@henrietta.com.pl:

Python 2.7.1(x86 MSI), binary downloaded from python.org, hangs quite reliably. 
Code:

with open(threadspecific, 'ab') as x:
 txt = unicode(str_or_unicode_parameter).encode('utf8')
 x.write(txt+'\r\n')

However, it doesn't hang if I insert a print statement between with and txt, 
with anything. Previous testing determined that it hangs on encode().

Aforementioned code is executed in a threading environment, and it hangs in 
thread that is spawned by master thread. Interpreter is left with an open file.

Same behaviour is repeatable on Python 2.5.1.

--
components: None
messages: 126390
nosy: henrietta
priority: normal
severity: normal
status: open
title: Python 2.7 hangs on Unicode+threading
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10923
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10923] Python 2.7 hangs on Unicode+threading

2011-01-16 Thread Piotr Maślanka

Piotr Maślanka piotr.masla...@henrietta.com.pl added the comment:

I runned it over again with code:

print 'Acquiring lock'
self.loglock.acquire()
print 'Attempting to convert'
if type(text) == unicode: text = text.encode('utf8', errors='strict')
print 'Opening '+threadspecific
with open(threadspecific, 'ab') as x: x.write(text+'\r\n')
print 'Closing '+threadspecific
self.loglock.release()
print 'Releasing lock'

It behaves erratically, sometimes working and yielding:
Acquiring lock
Acquiring lock
Attempting to convert
Opening threadspecific_master
Closing threadspecific_master
Releasing lock
Attempting to convert
Opening threadspecific_slave
Closing threadspecific_slave
Releasing lock

And sometimes hanging with:

Acquiring lock
Attempting to convert
Acquiring lock

Looks like a particularly nasty race condition. It gives off no exceptions. 
Platform is Windows 7 x64, running with admin privileges.

--
type:  - crash

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10923
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com