473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

running functions

Hello
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running? Is that what threading
is about?
Nov 22 '05 #1
24 1625
On 2005-11-16, Gorlon the Impossible <me********@yahoo.com> wrote:
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running?
Yes.
Is that what threading is about?


Exactly. Take a look at the "treading" module:

http://www.python.org/doc/current/li...threading.html

--
Grant Edwards grante Yow! BRILL CREAM is
at CREAM O' WHEAT in another
visi.com DIMENSION...
Nov 22 '05 #2
On 2005-11-16, Gorlon the Impossible <me********@yahoo.com> wrote:
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running?
Yes.
Is that what threading is about?


Exactly. Take a look at the "treading" module:

http://www.python.org/doc/current/li...threading.html

--
Grant Edwards grante Yow! BRILL CREAM is
at CREAM O' WHEAT in another
visi.com DIMENSION...
Nov 22 '05 #3
Gorlon the Impossible <me********@yahoo.com> wrote:
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running? Is that what threading
is about?


Threads are a complex answer. Subprocesses are a less complex answer.

(good sigmonster, have a biscuit)

--
\ "I have yet to see any problem, however complicated, which, |
`\ when you looked at it in the right way, did not become still |
_o__) more complicated." -- Paul Anderson |
Ben Finney
Nov 22 '05 #4
Gorlon the Impossible <me********@yahoo.com> wrote:
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running? Is that what threading
is about?


Threads are a complex answer. Subprocesses are a less complex answer.

(good sigmonster, have a biscuit)

--
\ "I have yet to see any problem, however complicated, which, |
`\ when you looked at it in the right way, did not become still |
_o__) more complicated." -- Paul Anderson |
Ben Finney
Nov 22 '05 #5
Gorlon the Impossible wrote:
Hello
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running? Is that what threading
is about?


Threading's a good answer if you really need to share all your memory.
A multiprocess solution is probably preferrable, though it depends on
the architecture.

It may be possible to do it in a single process (if, say, the MIDI
synth supports waitForMultipleObjects, select, async I/O, or an
equivalent thereof) without blocking.

Nov 22 '05 #6
Gorlon the Impossible wrote:
Hello
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running? Is that what threading
is about?


Threading's a good answer if you really need to share all your memory.
A multiprocess solution is probably preferrable, though it depends on
the architecture.

It may be possible to do it in a single process (if, say, the MIDI
synth supports waitForMultipleObjects, select, async I/O, or an
equivalent thereof) without blocking.

Nov 22 '05 #7
In article <11*************@corp.supernews.com>,
Grant Edwards <gr****@visi.com> wrote:
On 2005-11-16, Gorlon the Impossible <me********@yahoo.com> wrote:
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running?


Yes.
Is that what threading is about?


Exactly. Take a look at the "treading" module:

http://www.python.org/doc/current/li...threading.html

Nov 22 '05 #8
In article <11*************@corp.supernews.com>,
Grant Edwards <gr****@visi.com> wrote:
On 2005-11-16, Gorlon the Impossible <me********@yahoo.com> wrote:
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running?


Yes.
Is that what threading is about?


Exactly. Take a look at the "treading" module:

http://www.python.org/doc/current/li...threading.html

Nov 22 '05 #9
On Thu, 17 Nov 2005 00:08:02 GMT, cl****@lairds.us (Cameron Laird)
wrote:
In article <11*************@corp.supernews.com>,
Grant Edwards <gr****@visi.com> wrote:
On 2005-11-16, Gorlon the Impossible <me********@yahoo.com> wrote:
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running?
Yes.
Is that what threading is about?


Exactly. Take a look at the "treading" module:

http://www.python.org/doc/current/li...threading.html

.
.
.
I don't agree, Grant (although I salute the brevity
of your follow-up), and a couple of other correspon-
dents have already posted follow-ups that begin to
explore the alternatives.

If I were pursuing this, the first question I'd have
for Gorlon is whether he's OK with a "fire and for-
get" model. By that, I mean to ask if it's OK to
send the MIDI message, and then return immediately
to other Python work, OR whether Gorlon also needs
to stay in contact with the MIDI handler, and
perhaps react especially when the MIDI handler
finishes with the specific message. That choice is
crucial in a good concurrency design.


'good concurrency design' LOL... I'm not that proficient at
programming in general or Python...
You bring up some interesting points, though. I am just learning and
experimenting with programming MIDI events at this level. My function
sends a series of MIDI note-on and note-off messages and that's it so
far. But, I am trying to learn more and working towards a sort of
'live-coding' set-up for musical performance. So, eventually I will
want to be able to control other synth parameters with MIDI messages
and be able to start and stop different kinds of control functions 'on
the fly' so to speak. I checked out the threading module and its
working for what I am trying to do at the moment, but I am open to
suggestions and eager to learn all I can about other options. Thanks
for taking the time to respond.
I would be interested in hearing more about the subprocess approach...

So, Gorlon, yes, threading is a prominent member of
the family of facilities that address situations like
yours. It's not the only one, though.

Nov 22 '05 #10
On Thu, 17 Nov 2005 00:08:02 GMT, cl****@lairds.us (Cameron Laird)
wrote:
In article <11*************@corp.supernews.com>,
Grant Edwards <gr****@visi.com> wrote:
On 2005-11-16, Gorlon the Impossible <me********@yahoo.com> wrote:
I'm not sure how to phrase this question. I have a Python function
that sends MIDI messages to a synth. When I run it, I of course have
to wait until it is finished before I can do anything else with
Python. Is it possible to run this function and still be able to do
other things with Python while it is running?
Yes.
Is that what threading is about?


Exactly. Take a look at the "treading" module:

http://www.python.org/doc/current/li...threading.html

.
.
.
I don't agree, Grant (although I salute the brevity
of your follow-up), and a couple of other correspon-
dents have already posted follow-ups that begin to
explore the alternatives.

If I were pursuing this, the first question I'd have
for Gorlon is whether he's OK with a "fire and for-
get" model. By that, I mean to ask if it's OK to
send the MIDI message, and then return immediately
to other Python work, OR whether Gorlon also needs
to stay in contact with the MIDI handler, and
perhaps react especially when the MIDI handler
finishes with the specific message. That choice is
crucial in a good concurrency design.


'good concurrency design' LOL... I'm not that proficient at
programming in general or Python...
You bring up some interesting points, though. I am just learning and
experimenting with programming MIDI events at this level. My function
sends a series of MIDI note-on and note-off messages and that's it so
far. But, I am trying to learn more and working towards a sort of
'live-coding' set-up for musical performance. So, eventually I will
want to be able to control other synth parameters with MIDI messages
and be able to start and stop different kinds of control functions 'on
the fly' so to speak. I checked out the threading module and its
working for what I am trying to do at the moment, but I am open to
suggestions and eager to learn all I can about other options. Thanks
for taking the time to respond.
I would be interested in hearing more about the subprocess approach...

So, Gorlon, yes, threading is a prominent member of
the family of facilities that address situations like
yours. It's not the only one, though.

Nov 22 '05 #11
In article <bn********************************@4ax.com>,
Gorlon the Impossible <me********@yahoo.com> wrote:
Nov 22 '05 #12
In article <bn********************************@4ax.com>,
Gorlon the Impossible <me********@yahoo.com> wrote:
Nov 22 '05 #13
On Wed, 16 Nov 2005, sj*******@yahoo.com wrote:
Gorlon the Impossible wrote:
Is it possible to run this function and still be able to do other
things with Python while it is running? Is that what threading is
about?


Threading's a good answer if you really need to share all your memory. A
multiprocess solution is probably preferrable, though it depends on the
architecture.


I'm really curious about this assertion, which both you and Ben Finney
make. Why do you think multiprocessing is preferable to multithreading?

I've done a fair amount of threads programming, although in java rather
than python (and i doubt very much that it's less friendly in python than
java!), and i found it really fairly straightforward. Sure, if you want to
do complicated stuff, it can get complicated, but for this sort of thing,
it should be a doddle. Certainly, it seems to me, *far* easier than doing
anything involving multiple processes, which always seems like pulling
teeth to me.

For example, his Impossibleness presumably has code which looks like this:

do_a_bunch_of_midi(do, re, mi)
do_something_else(fa, so, la)

All he has to do to get thready with his own bad self is:

import threading
threading.Thread(do_a_bunch_of_midi, (do, re, mi)).start()
do_something_else(fa, so, la)

How hard is that? Going multiprocess involves at least twice as much code,
if not ten times more, will have lower performance, and will make future
changes - like interaction between the two parallel execution streams -
colossally harder.

tom

--
Remember when we said there was no future? Well, this is it.
Nov 22 '05 #14
On Wed, 16 Nov 2005, sj*******@yahoo.com wrote:
Gorlon the Impossible wrote:
Is it possible to run this function and still be able to do other
things with Python while it is running? Is that what threading is
about?


Threading's a good answer if you really need to share all your memory. A
multiprocess solution is probably preferrable, though it depends on the
architecture.


I'm really curious about this assertion, which both you and Ben Finney
make. Why do you think multiprocessing is preferable to multithreading?

I've done a fair amount of threads programming, although in java rather
than python (and i doubt very much that it's less friendly in python than
java!), and i found it really fairly straightforward. Sure, if you want to
do complicated stuff, it can get complicated, but for this sort of thing,
it should be a doddle. Certainly, it seems to me, *far* easier than doing
anything involving multiple processes, which always seems like pulling
teeth to me.

For example, his Impossibleness presumably has code which looks like this:

do_a_bunch_of_midi(do, re, mi)
do_something_else(fa, so, la)

All he has to do to get thready with his own bad self is:

import threading
threading.Thread(do_a_bunch_of_midi, (do, re, mi)).start()
do_something_else(fa, so, la)

How hard is that? Going multiprocess involves at least twice as much code,
if not ten times more, will have lower performance, and will make future
changes - like interaction between the two parallel execution streams -
colossally harder.

tom

--
Remember when we said there was no future? Well, this is it.
Nov 22 '05 #15
On Thu, 17 Nov 2005 23:29:16 +0000, Tom Anderson
<tw**@urchin.earth.li> wrote:
On Wed, 16 Nov 2005, sj*******@yahoo.com wrote:
Gorlon the Impossible wrote:
Is it possible to run this function and still be able to do other
things with Python while it is running? Is that what threading is
about?


Threading's a good answer if you really need to share all your memory. A
multiprocess solution is probably preferrable, though it depends on the
architecture.


I'm really curious about this assertion, which both you and Ben Finney
make. Why do you think multiprocessing is preferable to multithreading?

I've done a fair amount of threads programming, although in java rather
than python (and i doubt very much that it's less friendly in python than
java!), and i found it really fairly straightforward. Sure, if you want to
do complicated stuff, it can get complicated, but for this sort of thing,
it should be a doddle. Certainly, it seems to me, *far* easier than doing
anything involving multiple processes, which always seems like pulling
teeth to me.

For example, his Impossibleness presumably has code which looks like this:

do_a_bunch_of_midi(do, re, mi)
do_something_else(fa, so, la)

All he has to do to get thready with his own bad self is:

import threading
threading.Thread(do_a_bunch_of_midi, (do, re, mi)).start()
do_something_else(fa, so, la)

How hard is that? Going multiprocess involves at least twice as much code,
if not ten times more, will have lower performance, and will make future
changes - like interaction between the two parallel execution streams -
colossally harder.

tom


I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...
Nov 22 '05 #16
On Thu, 17 Nov 2005 23:29:16 +0000, Tom Anderson
<tw**@urchin.earth.li> wrote:
On Wed, 16 Nov 2005, sj*******@yahoo.com wrote:
Gorlon the Impossible wrote:
Is it possible to run this function and still be able to do other
things with Python while it is running? Is that what threading is
about?


Threading's a good answer if you really need to share all your memory. A
multiprocess solution is probably preferrable, though it depends on the
architecture.


I'm really curious about this assertion, which both you and Ben Finney
make. Why do you think multiprocessing is preferable to multithreading?

I've done a fair amount of threads programming, although in java rather
than python (and i doubt very much that it's less friendly in python than
java!), and i found it really fairly straightforward. Sure, if you want to
do complicated stuff, it can get complicated, but for this sort of thing,
it should be a doddle. Certainly, it seems to me, *far* easier than doing
anything involving multiple processes, which always seems like pulling
teeth to me.

For example, his Impossibleness presumably has code which looks like this:

do_a_bunch_of_midi(do, re, mi)
do_something_else(fa, so, la)

All he has to do to get thready with his own bad self is:

import threading
threading.Thread(do_a_bunch_of_midi, (do, re, mi)).start()
do_something_else(fa, so, la)

How hard is that? Going multiprocess involves at least twice as much code,
if not ten times more, will have lower performance, and will make future
changes - like interaction between the two parallel execution streams -
colossally harder.

tom


I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...
Nov 22 '05 #17
Gorlon the Impossible wrote:
I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...


The reason multiprocess is easier is that you have enforced separation.
Multiple processes / threads / whatever that share reads and writes
into shared memory are rife with irreproducible bugs and untestable
code. Processes must be explicit about their sharing (which is where
the bugs occur), so those parts of the code cane be examined carefully.
If you program threads with shared nothing and communication over Queues
you are, in effect, using processes. If all you share is read-only
memory, similarly, you are doing "easy" stuff and can get away with it.
In all other cases you need to know things like "which operations are
indivisible" and "what happens if I read part of this from before an
update and the other after the update completes, .....

That is why threads that don't do trivial things are so scary.

--Scott David Daniels
sc***********@acm.org
Nov 22 '05 #18
Gorlon the Impossible wrote:
I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...


The reason multiprocess is easier is that you have enforced separation.
Multiple processes / threads / whatever that share reads and writes
into shared memory are rife with irreproducible bugs and untestable
code. Processes must be explicit about their sharing (which is where
the bugs occur), so those parts of the code cane be examined carefully.
If you program threads with shared nothing and communication over Queues
you are, in effect, using processes. If all you share is read-only
memory, similarly, you are doing "easy" stuff and can get away with it.
In all other cases you need to know things like "which operations are
indivisible" and "what happens if I read part of this from before an
update and the other after the update completes, .....

That is why threads that don't do trivial things are so scary.

--Scott David Daniels
sc***********@acm.org
Nov 22 '05 #19
On 2005-11-18, Scott David Daniels <sc***********@acm.org> wrote:
Gorlon the Impossible wrote:
I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...
The reason multiprocess is easier is that you have enforced
separation. Multiple processes / threads / whatever that share
reads and writes into shared memory are rife with
irreproducible bugs and untestable code.


There can be problems, but you make it sound way worse than it
really is. I've been doing threaded SW for a lot of years
(yikes! almost 25), and it's just not that hard to deal with
shared objects/variables -- especially in Python with its GIL.

I think it's easier and more intuitive than forking.

I've written a lot of (admittedly not huge) Python programs
using threading (some with 30-40 thread), and I don't remember
ever tripping over anything significant. I think dealing with
shared objects is easier than figuring out how to do
inter-process communications using sockets or Posix shared
memory or whatnot. It's not difficult if you don't have to do
any communication between processes, but in that case, shared
objects aren't a problem either.

[...]
That is why threads that don't do trivial things are so scary.


Maybe I've just been using threads too long, but I don't think
they're any more scary than software in general is scary.

--
Grant Edwards grante Yow! I LIKE Aisle 7a.
at
visi.com
Nov 22 '05 #20
On 2005-11-18, Scott David Daniels <sc***********@acm.org> wrote:
Gorlon the Impossible wrote:
I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...
The reason multiprocess is easier is that you have enforced
separation. Multiple processes / threads / whatever that share
reads and writes into shared memory are rife with
irreproducible bugs and untestable code.


There can be problems, but you make it sound way worse than it
really is. I've been doing threaded SW for a lot of years
(yikes! almost 25), and it's just not that hard to deal with
shared objects/variables -- especially in Python with its GIL.

I think it's easier and more intuitive than forking.

I've written a lot of (admittedly not huge) Python programs
using threading (some with 30-40 thread), and I don't remember
ever tripping over anything significant. I think dealing with
shared objects is easier than figuring out how to do
inter-process communications using sockets or Posix shared
memory or whatnot. It's not difficult if you don't have to do
any communication between processes, but in that case, shared
objects aren't a problem either.

[...]
That is why threads that don't do trivial things are so scary.


Maybe I've just been using threads too long, but I don't think
they're any more scary than software in general is scary.

--
Grant Edwards grante Yow! I LIKE Aisle 7a.
at
visi.com
Nov 22 '05 #21
Quoth Grant Edwards <gr****@visi.com>:
| On 2005-11-18, Scott David Daniels <sc***********@acm.org> wrote:
| > Gorlon the Impossible wrote:
| >
| >> I have to agree with you there. Threading is working out great for me
| >> so far. The multiprocess thing has just baffled me, but then again I'm
| >> learning. Any tips or suggestions offered are appreciated...
| >
| > The reason multiprocess is easier is that you have enforced
| > separation. Multiple processes / threads / whatever that share
| > reads and writes into shared memory are rife with
| > irreproducible bugs and untestable code.
|
| There can be problems, but you make it sound way worse than it
| really is. I've been doing threaded SW for a lot of years
| (yikes! almost 25), and it's just not that hard to deal with
| shared objects/variables -- especially in Python with its GIL.
|
| I think it's easier and more intuitive than forking.
|
| I've written a lot of (admittedly not huge) Python programs
| using threading (some with 30-40 thread), and I don't remember
| ever tripping over anything significant. I think dealing with
| shared objects is easier than figuring out how to do
| inter-process communications using sockets or Posix shared
| memory or whatnot. It's not difficult if you don't have to do
| any communication between processes, but in that case, shared
| objects aren't a problem either.

To understand the point behind this, it's important to understand
what easy and difficult are about here. Are we talking about easy
to get something done? Easy to get something absolutely reliable?
Easy to screw up?

The point is not that it's hard to import the threading module and
fire off a thread to do something. On the contrary, if anything
maybe it's too easy. The thing that's supposed to be difficult is
predictable, reliable execution, in in principle because of a
compounding effect on the number of possible states.

It should be scary. Whether it should be prohibitively scary is
the kind of abstract debate that will never really be resolved here.

I got into BeOS when it came out a few years back, and learned to
program in Python to its native UI, where each window has its own
thread. It works fine for me, and I personally support the decision
to do it that way, but later there was a school of thought, including
some ex-Be engineers among the proponents, that held it to be a big
mistake. Apparently this was after all a common pitfall for application
developers, who would release code that could deadlock or go wrong
in various ways due to unanticipated thread interactions. All of
these application developers were working in C++, and I'm sure that
made them a little more vulnerable. Thank heavens Python isn't
capable of real concurrent execution, for one thing, and also it's
surely easier to put together generic functions for queueing and
that sort of thing, so I could afford to be more disciplined about
sharing data between threads. But in the end there were a lot more
of them, their applications were bigger or more adventurous and more
widely used, so there were a lot of opportunities for things to happen
to them that have never happened to me. As I said, I thought their
design was good, but maybe they just didn't get the word out like
they should have - that threads are scary.

Donn Cave, do**@drizzle.com

(posting this from a Python/BeOS API newsreader)
Nov 22 '05 #22
Quoth Grant Edwards <gr****@visi.com>:
| On 2005-11-18, Scott David Daniels <sc***********@acm.org> wrote:
| > Gorlon the Impossible wrote:
| >
| >> I have to agree with you there. Threading is working out great for me
| >> so far. The multiprocess thing has just baffled me, but then again I'm
| >> learning. Any tips or suggestions offered are appreciated...
| >
| > The reason multiprocess is easier is that you have enforced
| > separation. Multiple processes / threads / whatever that share
| > reads and writes into shared memory are rife with
| > irreproducible bugs and untestable code.
|
| There can be problems, but you make it sound way worse than it
| really is. I've been doing threaded SW for a lot of years
| (yikes! almost 25), and it's just not that hard to deal with
| shared objects/variables -- especially in Python with its GIL.
|
| I think it's easier and more intuitive than forking.
|
| I've written a lot of (admittedly not huge) Python programs
| using threading (some with 30-40 thread), and I don't remember
| ever tripping over anything significant. I think dealing with
| shared objects is easier than figuring out how to do
| inter-process communications using sockets or Posix shared
| memory or whatnot. It's not difficult if you don't have to do
| any communication between processes, but in that case, shared
| objects aren't a problem either.

To understand the point behind this, it's important to understand
what easy and difficult are about here. Are we talking about easy
to get something done? Easy to get something absolutely reliable?
Easy to screw up?

The point is not that it's hard to import the threading module and
fire off a thread to do something. On the contrary, if anything
maybe it's too easy. The thing that's supposed to be difficult is
predictable, reliable execution, in in principle because of a
compounding effect on the number of possible states.

It should be scary. Whether it should be prohibitively scary is
the kind of abstract debate that will never really be resolved here.

I got into BeOS when it came out a few years back, and learned to
program in Python to its native UI, where each window has its own
thread. It works fine for me, and I personally support the decision
to do it that way, but later there was a school of thought, including
some ex-Be engineers among the proponents, that held it to be a big
mistake. Apparently this was after all a common pitfall for application
developers, who would release code that could deadlock or go wrong
in various ways due to unanticipated thread interactions. All of
these application developers were working in C++, and I'm sure that
made them a little more vulnerable. Thank heavens Python isn't
capable of real concurrent execution, for one thing, and also it's
surely easier to put together generic functions for queueing and
that sort of thing, so I could afford to be more disciplined about
sharing data between threads. But in the end there were a lot more
of them, their applications were bigger or more adventurous and more
widely used, so there were a lot of opportunities for things to happen
to them that have never happened to me. As I said, I thought their
design was good, but maybe they just didn't get the word out like
they should have - that threads are scary.

Donn Cave, do**@drizzle.com

(posting this from a Python/BeOS API newsreader)
Nov 22 '05 #23
On Thu, 17 Nov 2005, Scott David Daniels wrote:
Gorlon the Impossible wrote:
I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...
The reason multiprocess is easier is that you have enforced separation.
Multiple processes / threads / whatever that share reads and writes into
shared memory are rife with irreproducible bugs and untestable code.
Processes must be explicit about their sharing (which is where the bugs
occur), so those parts of the code cane be examined carefully.


That's a good point.
If you program threads with shared nothing and communication over Queues
you are, in effect, using processes. If all you share is read-only
memory, similarly, you are doing "easy" stuff and can get away with it.
In all other cases you need to know things like "which operations are
indivisible" and "what happens if I read part of this from before an
update and the other after the update completes, .....


Right, but you have exactly the same problem with separate processes -
except that with processes, having that richness of interaction is so
hard, that you'll probably never do it in the first place!

tom

--
science fiction, old TV shows, sports, food, New York City topography,
and golden age hiphop
Nov 22 '05 #24
On Thu, 17 Nov 2005, Scott David Daniels wrote:
Gorlon the Impossible wrote:
I have to agree with you there. Threading is working out great for me
so far. The multiprocess thing has just baffled me, but then again I'm
learning. Any tips or suggestions offered are appreciated...
The reason multiprocess is easier is that you have enforced separation.
Multiple processes / threads / whatever that share reads and writes into
shared memory are rife with irreproducible bugs and untestable code.
Processes must be explicit about their sharing (which is where the bugs
occur), so those parts of the code cane be examined carefully.


That's a good point.
If you program threads with shared nothing and communication over Queues
you are, in effect, using processes. If all you share is read-only
memory, similarly, you are doing "easy" stuff and can get away with it.
In all other cases you need to know things like "which operations are
indivisible" and "what happens if I read part of this from before an
update and the other after the update completes, .....


Right, but you have exactly the same problem with separate processes -
except that with processes, having that richness of interaction is so
hard, that you'll probably never do it in the first place!

tom

--
science fiction, old TV shows, sports, food, New York City topography,
and golden age hiphop
Nov 22 '05 #25

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

Similar topics

7
by: lawrence | last post by:
Suppose I create dynamic web pages with 3 functions (which call other functions to make everything happen, but these 3 you might think of as being the top layer): registerSessions();...
6
by: Perttu Pulkkinen | last post by:
I just want to ask php-community, are they running too fast with new versions. Why: 1) Its not so nice to load 4.2x and then come back couople of months later to find out that php 5 is out while...
2
by: Michael Schmitt | last post by:
Hello. What is the usual way for running functions in parallel on a multiple-processor machine. Actually I want to run a single computationally expensive function with different parameter sets....
7
by: Joecx | last post by:
Hi Does anyone have the code or maybe give me a start on how to detect if my program is already running if someone tries to run it again while it's already running? I know I could do this with a...
10
by: ThunderMusic | last post by:
Hi, How can I get if the Windows running is a server version? Is there a property somewhere that can tell me if the Windows version is a server edition (including server, advanced server, web...
16
by: TB | last post by:
Hi all: If you think that the following comments are absolute amateurish, then please bear with me, or simply skip this thread. A couple of months back I made the decision to initiate a...
2
by: Kevin Hodgson | last post by:
Is there any way in a .NET App to detect if it is being run under Terminal Server? I have some functions of my program (like launching emails, and saving files) that need to be handled...
12
by: David Bear | last post by:
I would like to write some code that would randomly select a function from a list of functions and call it. I was looking in the globals names space and randomly selecting items that were of type...
60
by: harshal | last post by:
Hi all, Can we read the stack frame's of the current process. as we know that whenever a function call is made in c new functions stack frame is created and pushed on to the stack. and when the...
12
by: Shadlan | last post by:
Hi. I need to know if a service is running on my server. Is there any PHP instruction that I can use to do this?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.