Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sys': 0.07; 'filename': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terminates': 0.09; 'python': 0.11; 'def': 0.12; '2.7': 0.14; 'thread': 0.14; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'simplified': 0.16; 'subject:skip:m 10': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'import': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'skip:" 30': 0.26; 'header:X-Complaints-To:1': 0.27; 'code': 0.31; 'file': 0.32; 'class': 0.32; 'run': 0.32; 'skip:# 10': 0.33; 'skip:t 40': 0.33; 'skip:_ 10': 0.34; 'could': 0.34; 'anybody': 0.35; 'but': 0.35; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'email addr:gmail.com': 0.63; 'more': 0.64 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: multithreading in python Date: Tue, 13 Aug 2013 11:22:56 +0000 (UTC) References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 174.32.174.30 User-Agent: XPN/1.2.6 (Street Spirit ; Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376392996 news.xs4all.nl 15995 [2001:888:2000:d::a6]:34427 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52452 samaneh.yahyapour@gmail.com wrote: > hi > my program work by 4 thread but when i use more thread it terminates > > I simplified your code so anybody could run it, and tested it inside Komodo IDE, on Python 2.7 #!/usr/bin/env python import sys import os import time import threading class MyClass(): def __init__(self): i = 0 while i<10: work = WorkClass(i) thread1 = threading.Thread(target=work.item_thread) thread1.start() i = i+1 time.sleep(0.01) class WorkClass(): def __init__(self, parm): self.parm = str(parm) def item_thread(self): print "beginning thread", self.parm for filename in os.listdir("."): data = "thread " + self.parm + " filename " + filename + "\n" print data time.sleep(0.5) print "ENDDDDDDDDDDDDDDDDDDDDDDDDDDDD " + self.parm x = MyClass() print "Finishing main thread" When the -- Signature file not found