thread.start_new_thread question

  • Thread starter Konstantin Veretennicov
  • Start date
K

Konstantin Veretennicov

Hi,

Just curious: . . .
start_new_thread(function, args[, kwargs])
. . .

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

- kv
 
B

Brian

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 said:
Hi,

Just curious:

. . .
start_new_thread(function, args[, kwargs])
. . .

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

- kv
 
K

Konstantin Veretennicov

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_thread 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?
 
P

Peter Hansen

Konstantin said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,252
Messages
2,571,267
Members
47,908
Latest member
MagdalenaR

Latest Threads

Top