On Wed, 08 Feb 2006 18:14:14 -0500
Kent Johnson <[EMAIL PROTECTED]> wrote:
> > Sorry, I missed to insert the time.sleep(0.1) I used in my original while
> > loop into the example above.
> > The reason for using time.sleep() is that I need to avoid lots of loops
> > over an empty buffer.
> > The
Michael Lange wrote:
> Sorry, I missed to insert the time.sleep(0.1) I used in my original while
> loop into the example above.
> The reason for using time.sleep() is that I need to avoid lots of loops over
> an empty buffer.
> The amount of time until the producer thread reads a new data fragmen
On Wed, 08 Feb 2006 13:47:39 -0500
Kent Johnson <[EMAIL PROTECTED]> wrote:
> > while self.recording:
> > data = []
> > while not self.rec_queue.empty():
> > try:
> >data.append(self.rec_queue.get(block=0))
> > except Queue.Empty:
> >
Michael Lange wrote:
> On Wed, 08 Feb 2006 08:37:18 -0500
> Kent Johnson <[EMAIL PROTECTED]> wrote:
>>child thread 2:
>>
>> while self.recording:
>> data = self.rec_queue.get()
>> for d in data:
>> self._waveobj.writeframesraw(d)# write data to file
>
On Wed, 08 Feb 2006 08:37:18 -0500
Kent Johnson <[EMAIL PROTECTED]> wrote:
> Another architecture you might consider is to have thread 1 put the
> actual acquired buffers into two Queues that are read by the two
> consumer threads. This would save you a lot of copying and give you a
> cleaner i
Michael Lange wrote:
> On Tue, 7 Feb 2006 23:31:06 +0100
> Michael Lange <[EMAIL PROTECTED]> wrote:
>
>
>>So I think I need two Condition objects here; it is most important here that
>>thread 1 does not
>>block to minimize the risk of recording buffer overruns, but from reading the
>>docs I am
On Tue, 7 Feb 2006 23:31:06 +0100
Michael Lange <[EMAIL PROTECTED]> wrote:
>
> So I think I need two Condition objects here; it is most important here that
> thread 1 does not
> block to minimize the risk of recording buffer overruns, but from reading the
> docs I am
> not sure about the correc
On Tue, 07 Feb 2006 06:02:45 -0500
Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> One way to make this code thread-safe is to use a threading.Condition()
> instead of a boolean variable:
>
> thread 1 does:
>
> self.lock.acquire()
> if condition:
> self.name = 'bob'
> else:
Hi Kent,
To answer your first concern, not all changes need to be intercepted
by one the child thread. I have not given out all the details about
the program, but if the parent thread gets certain values from the
database, it will take actions that may affect the child thread other
than just by se
Bernard Lebel wrote:
> Hi Kent,
>
> I have put together a little script to give a rough idea about what
> the program does.
>
> http://www.bernardlebel.com/scripts/nonxsi/help/bl_threadtest.py
In this code, there is no guarantee that callMeWhenAttributeChanged()
will see every change to oBernar
Michael Lange wrote:
> I have used a boolean to control access to a variable that is used by two
> threads,
> as in this example:
>
> thread 1 does:
>
> while self.locked:
> pass
> self.locked = 1
> if condition:
> self.name = 'bob'
> else:
> self.name = '
On Mon, 06 Feb 2006 18:34:18 -0500
Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> It sounds like you have some attributes that you are using as flags to
> allow one thread to control another. There are definitely some pitfalls
> here. You probably want to use threading.Condition or Queue.Queue to
Hi Kent,
I have put together a little script to give a rough idea about what
the program does.
http://www.bernardlebel.com/scripts/nonxsi/help/bl_threadtest.py
The true program does this:
- the top program file imports a module called fcJob
- the top program instantiate the only class in the
Bernard Lebel wrote:
> Example:
>
> - Class instance Bernard has attribute "name", whose value is "bernard".
> - A function in a thread tests the value of "name". If "name" ==
> "bernard", do nothing.
> - A function in another thread, for some reason, changes "name" to "bob".
> - The first functio
hi Kent,
See [Bernard] below.
On 2/6/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bernard Lebel wrote:
> > Hello,
> >
> > I have an instance attribute (a few characters string) that two
> > separate threads may change, potentially both at the same time.
> > My program doesn't implement thread s
Bernard Lebel wrote:
> Hello,
>
> I have an instance attribute (a few characters string) that two
> separate threads may change, potentially both at the same time.
> My program doesn't implement thread safety for this particular task.
>
> So far I have never run into issues with this, but I have
16 matches
Mail list logo