f



About threading.Thread

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 =3D threading.enumerate()
		for thread in threads:
			print(thread.getName())
		time.sleep(3)


def fun():
	a =3D threading.Thread(target=3Dhello(), name=3D'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
0
UTF
4/5/2014 5:02:59 AM
comp.lang.python 77058 articles. 6 followers. Post Follow

0 Replies
726 Views

Similar Articles

[PageSpeed] 28

Reply:

Similar Artilces:

thread, threading; how to kill a thread?
Greetings Pythonists; I have limited experience with threaded apps and plenty with old style forked heavyweight multi-processing apps. Using Python 2.3.3 on a Redhat 7.x machine. Wondering if there is a simple way from a main python program to kill a running thread? I see with the 'threading' module the way daemonic threads behave when the main program finishes. But suppose we have a simple thread running a function like; def timedLoop(): while True: time.sleep(10) doSomething() All I am trying to do is stop that thread immediatly from the main program and i...

To thread or not to thread
My app needs to check a number of things on the web. This can be done in the background. I use idHTTP to pull data in. This process is broken down into small parts and the subroutinen are called in the OnIdle handler of the main form. I notice that sometimes idHTTP needs a considerable time to build the connection/fetch the data and the application doesn't repond to user actions during such periods. To cope with this I have now implemented the web data fetching in a thread with priority tpIdle. I think the problem of non-response has gone, ut it is difficult to test. Am...

Thread or not thread
Hello, i read some document that say enabling threads (in Bind 9.x compiling), giv= e less performance than disabling threads, in a 32 bit environment (with 2 = cpu), using Bind DLZ (with Postgresql DB). I found something here: http://zaphods.net/~zaphodb/high-performance-bind9.html Do you suggest enabling threads with DLZ or not? Thank you! Francesco= ...

thread or threads ?
For some time now, I've been checking out tcl, tk, tls and threads from sourceforge. Recently, my cvs went berserk (I passed it a subdirectory with trailing slash for update, but I'm not sure if that was really the reason), and instead of updating just that directory, it checked out all modules. Among these modules was "thread". I checked for what was more recent, and it looked like thread had more recent checkins than threads. But "thread" doesn't even configure: > ../../../cvs/sourceforge/thread/configure checking for correct TEA configuration... ok (T...

threading a thread
I have a program written in Python that checks a class B network (65536 hosts) for web servers. It does a simple TCP socket connect to port 80 and times out after a certain periods of time. The program is threaded and can do all of the hosts in about 15 minutes or so. I'd like to make it so that I can check for other open ports (instead of just port 80) and I'd like to thread the port checks as well. Right now I'm just prototyping and the threaded hosts portion works very well for my needs. I'd just like to add a threaded ports check and wanted to know if anyone had don...

To thread or not to thread
Hello, I was recently reading an article on threading in python and I came across Global Interpreter Lock,now as a novince in python I was cusrious about 1.Is writing a threaded code in python going to perform well than a normal python code.If so on what basis can it performance be measured. 2.Is writing a threaded code in python better than a code written in C/C++ using PTHREADS. If someone can comment on these questions, it would be great. On 2005-07-28, Sidd <iamsidd@gmail.com> wrote: > I was recently reading an article on threading in python and I > came across Glo...

Thread or threads.
thinking of writing a perl script with concurrent abilities. which Module is better 'Thread' or 'threads' ? thx. On Mon, 30 Jun 2008 05:24:19 -0700 (PDT), nadav <nadavh@gmail.com> wrote: >thinking of writing a perl script with concurrent abilities. >which Module is better 'Thread' or 'threads' ? > >thx. Thread (capital T) is obsolete. -- I'm not really a human, but I play one on earth. http://zentara.net/CandyGram_for_Mongo.html nadav wrote: > thinking of writing a perl script with concurrent abilities. > which Module is bette...

To thread or not to thread ?
The threads of discussion about threads have been enlightening in exposing some of the low level issues which could possibly affect MT code and, more importantly, served also to bring awareness to the unsuspecting (me for one). It leaves me wondering if writing MT code is even to be pursued at this point in time, or at least "where's the guidebook to read is that will facilitate the writing of MT code without engaging compiler-level gotchas?". Can the low level issues be dealt with in the short term by following certain rules, perhaps platform-specific ones, or is robust MT code ...

another thread on Python threading
Hi, I've recently been working on an application[1] which does quite a bit of searching through large data structures and string matching, and I was thinking that it would help to put some of this CPU-intensive work in another thread, but of course this won't work because of Python's GIL. There's a lot of past discussion on this, and I want to bring it up again because with the work on Python 3000, I think it is worth trying to take a look at what can be done to address portions of the problem through language changes. Also, the recent hardware trend towards multicore proces...

thread::release [thread::id] of main thread
I would like to put this into discussion: In the main thread write: package re Thread thread::release [thread::id] Shall a scripting language take precautions for making such errors and throw an error? or shall it simply do what the user requests? I already mentioned this at sourceforge but didn't write an explicit bug-report. thx ...

threads within a thread
I have a program that uses threads to quickly check class B networks (65,536) hosts for public web servers. It works great. I'd like to check for other servers as well. Basically, I've got the hosts threaded. Now, I'd like to thread the ports so that while the hosts are being probed concurrently that ports on the hosts could be probed concurrently as well. It might look like this: A Thread host A Thread port 80 port 443 port 25 host A Thread port 445 port 139 host A Thread ... I can demonstrate actually code (with only threaded ho...

Sub thread and Thread ?
Hi, all: Can I build 2 sub threads in another thread? which means: main call thread A ; Thread A call thread A1; call Thread A2; ; Thanks for any comments. bin YE yezi wrote: > Hi, all: > > Can I build 2 sub threads in another thread? which means: If in the pseudo code below 'call' means 'create' then yes, most thread APIs allow threads to create threads. > main > > call thread A > > ; > > Thread A > call thread A1; > call Thread A2; > > ; > > Tha...

threads creating threads ..
Hi, scenario: I create a thread X using pthread_create(). thread X then creates thread Y using pthread_create(). thread X then completes it's operations and returns thus terminating the thread X. question: What happens to thread Y? I need to have thread Y continue to run after thread X has terminated. I haven't coded this yet, just need to know in advance if there is anything i need to do. My application is already threaded using pthreads, this is a modification needed to handle some extra functionaity. I'm using codwarrior 8.3 on mac osX (10.3) and pth...

Thread within a thread
Is it possible to call a thread (pthread) from within a thread invocation ? If I correctly pthread_join() the new thread from the calling thread, does it make good design sense ? <raseelbhagat@gmail.com> wrote in message news:de3c9fd5-5d89-4a0c-a2ac-14a1f7da0784@i28g2000prd.googlegroups.com... > Is it possible to call a thread (pthread) from within a thread > invocation ? Yes. > If I correctly pthread_join() the new thread from the calling thread, > does it make good design sense ? Well, perhaps it makes 100% complete sense for your particular application; I need mo...

Web resources about - About threading.Thread - comp.lang.python

Threading - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

EYEBROW THREADING NBC 10 SPECIAL - YouTube
AN NBC 10 SPECIAL ON EYEBROW THREADING BY SALON PANACHE. CRANSTON RI.

WordPress, Tumblr and Facebook: Threading Social Through the Blogosphere
Matt Mullenweg and Toni Schneider of Automattic, speaking at the Le Web conference. For today’s blogging platforms, hosting a compelling set ...

The art of threading the needle, as demonstrated by a Lotus Exige
Professional racing drivers are a different breed than the rest of us mere mortals. While fear &ndash; of dying, of killing or of simply making ...

Rand Paul threading the foreign policy needle
Rand Paul threading the foreign policy needle by digby Over at Salon this morning I wrote about Rand Paul's "foreign policy." That's in scare ...

Threading and Unconditional Arms releasing a split for Native Sound's new 7" series
by Andrew Sacher Threading The Native Sound is introducing a new split 7" series which begins on February 24 with Unconditional Arms / Threading, ...

Threading Some Trends Together
This post by Shel Israel and this post by Steve Rubel bear reading and examining. There's something afoot, and it deals with several pieces of ...

Google makes Gmail threading a choice
Gmail users will be able to toggle between the service's threaded "conversation" view of mail exchanges and a more traditional style. The option ...

Threading the needle on Syria and Iran
While the world's attention has rightly been focused on Syria for the past week, it is Iran that may well move to center stage in the coming ...

New Multicore Tool For Slick Threading Power
Vector Fabrics smooths multicore software optimization

Resources last updated: 1/27/2016 2:15:05 AM