473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

thread.start_ne w_thread question

Hi,

Just curious:
import thread
help(thread.sta rt_new_thread)

. . .
start_new_threa d(function, args[, kwargs])
. . .

Second argument is mandatory. Is it incidental or for a reason?

- kv
Jul 19 '05 #1
3 4948
Hi KV,

Here's a site that provides an easy, beginners example of how to do
threading. You might find this useful too... :-)

http://www.codesampler.com/python.htm
(Look for the "Spawning Threads" section.)

Brian
---
Konstantin Veretennicov wrote:
Hi,

Just curious:
import thread
help(thread .start_new_thre ad)


. . .
start_new_threa d(function, args[, kwargs])
. . .

Second argument is mandatory. Is it incidental or for a reason?

- kv

Jul 19 '05 #2
On 6/17/05, Brian <de**********@n etscape.com> wrote:
Hi KV,

Here's a site that provides an easy, beginners example of how to do
threading. You might find this useful too... :-)

http://www.codesampler.com/python.htm
(Look for the "Spawning Threads" section.)


Thank you, but that doesn't answer my question. I was asking if there
is a reason that "args" is not optional.

Oftentimes functions I use to start_new_threa d have no arguments (they
may get data from bound instance or from closure), but still I have to
pass empty "args", always wondering, why? Python lib generally has a
very nice and convenient interface and tries to supply sensible
defaults when possible. That "args" is a required argument is a
mystery to me :)

- kv

A. No.
Q. Is top posting OK?
Jul 19 '05 #3
Konstantin Veretennicov wrote:
Thank you, but that doesn't answer my question. I was asking if there
is a reason that "args" is not optional.


At the risk of increasing your frustration, I'm going avoid answering
your question as well and simply point out that if you use the
"threading" module, as is recommended, you won't have to deal with this
issue at all, and your code will generally be simpler.

(To answer your real question I'd have to check the docs for "thread"
and, since I _never_ use that module in spite of heavy use of threading,
I can't help you more... sorry.)

-Peter
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
2908
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.3.1 (final). Python 2.3.1 is a pure bug fix release of Python 2.3, released in late July. A number of obscure crash-causing bugs have been fixed, various memory leaks have been squished, but no new features have been added to the language or to the library. For more information on Python 2.3.1, including download links for...
3
7655
by: Thomas Schmid | last post by:
Hi there, I wrote a tcp server which listens on a port. When he gets a new connection, he starts a new thread like this: thread.start_new_thread(self.ConnectionHandler, (conn,)) where conn is the socket for the connection. After I started the server, I can see one running process under Linux, which is ok. But once I connected to the Server, I always see two processes where one is the parent of the other. I think this should be
0
1373
by: Fazan | last post by:
I'm using Tim Golden's WMI implementation (http://tgolden.sc.sabren.com/python/wmi.html) version 0.6 along with pywin32 build 202. I'm able to successfully query WMI in the main thread but not in a separate thread. Here's a little snippet of sample code that fails for me: ---- import thread, threading, wmi def wmiTest(c, callee):
15
1596
by: Valkyrie | last post by:
Refering to the following codes I found, there is nothing displayed in the console, may I ask why? def thrd(param): # the thread worker function print "Received",param import thread for i in range(5): # start five threads passing i to each one thread.start_new_thread(thrd,(i,))
2
6826
by: Jerry Sievers | last post by:
Fellow Pythonists; According to the docs +-----------------+ |interrupt_main(|)| +-----------------+ Raise a KeyboardInterrupt in the main thread. A subthread can use this function to interrupt the main thread. New in version 2.3. Therefore, I was expecting this short test prog to run and then finish
2
25674
by: Leo Jay | last post by:
Dear all, i would like to get the return value of all threads e.g. def foo(num): if num>10: return 1 elif num>50: return 2
1
3714
by: Luxore | last post by:
Hello, I am trying to create threaded python project and I'm running into some weird Python variable scoping. I am using the "thread" module (I know, it's old and I should be using threading)... but for example: <code> import thread
3
2178
by: Salvatore Di Fazio | last post by:
Hi guys, when I close the application I get the following error: ----------------------------- Traceback (most recent call last): File "main.py", line 88, in <module> while exit : pass KeyboardInterrupt Unhandled exception in thread started by Error in sys.excepthook:
16
2772
by: Hendrik van Rooyen | last post by:
I thought I would share this nasty little gotcha with the group. Consider the following code fragment: <start> print 'starting kbd thread' keyboard_thread = thread.start_new_thread(kbd_driver (port_q,kbd_q)) print 'starting main loop' error = Mainloop(s,port_q,active_q_list) <end>
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.