[ python-Bugs-1339045 ] Threading misbehavior with lambdas

SourceForge.net noreply at sourceforge.net
Thu Oct 27 02:21:39 CEST 2005


Bugs item #1339045, was opened at 2005-10-27 02:21
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1339045&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Threads
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Maciek Fijalkowski (fijal)
Assigned to: Nobody/Anonymous (nobody)
Summary: Threading misbehavior with lambdas

Initial Comment:
suppose i write:
def f(x):
  print x()

for i in range(3):
  f ( lambda : i )

I got 0,1,2

But when I write

for i in range(3):
  thread . start_new_thread ( f , ( lambda : i ) )

I got 2,2,2

Probably I don't get well design principles, but isn't
it against thread consistency? (as long as threads does
not interact with each other, interlace doesn't matter).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1339045&group_id=5470


More information about the Python-bugs-list mailing list