Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69711

About threading.Thread

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <zhangpeipei812@outlook.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; '(python': 0.07; 'subject:skip:t 10': 0.09; 'python': 0.11; 'def': 0.12; 'thread': 0.14; 'a.py': 0.16; 'b.py': 0.16; 'file1': 0.16; 'received:65.55.116.7': 0.16; 'run:': 0.16; 'true:': 0.16; 'advance.': 0.19; 'seems': 0.21; 'import': 0.22; 'received:65.55.116': 0.24; 'question': 0.24; 'code': 0.31; 'file:': 0.31; 'subject:About': 0.31; 'anyone': 0.31; 'but': 0.35; 'version:': 0.36; 'thank': 0.38; 'to:addr:python-list': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:t 30': 0.61; 'new': 0.61; 'from:charset:utf-8': 0.61; 'here:': 0.62; 'skip:n 10': 0.64; 'regards.': 0.65
X-TMN [t1KlJHX79jJYD07RMKvK/848i1RAAYP8]
X-Originating-Email [zhangpeipei812@outlook.com]
From 张佩佩 <zhangpeipei812@outlook.com>
To <python-list@python.org>
Subject About threading.Thread
Date Sat, 5 Apr 2014 13:02:59 +0800
MIME-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
X-Mailer Microsoft Outlook 15.0
Thread-Index Ac9QijvkOoTX4tqJSYK1sJJfOoCmcg==
Content-Language en-us
X-OriginalArrivalTime 05 Apr 2014 05:03:15.0194 (UTC) FILETIME=[59F585A0:01CF508C]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8917.1396674262.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1396674262 news.xs4all.nl 2835 [2001:888:2000:d::a6]:45352
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:69711

Show key headers only | View raw


Hello guys:
  I have an question on threading.Thread
My code is here:
File1:
a.py
import threading
import time

def hello():
	while True:
		print('hello')
		threads = threading.enumerate()
		for thread in threads:
			print(thread.getName())
		time.sleep(3)


def fun():
	a = threading.Thread(target=hello(), name='hello')
	print("a file: I won't display!")
	a.start()

File2:
b.py
import time

from a import fun

fun()

print("b file: I won't display!")


When I run: python b.py (python version: 2.7.6, 3.3.5, 3.4.0)
It seems that threading.Thread() in file1 not create a new thread but use MainThread.
Anyone can explain this ?
Thank you in advance.

Best regards.
peipei

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

About threading.Thread 张佩佩 <zhangpeipei812@outlook.com> - 2014-04-05 13:02 +0800

csiph-web