Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Immortality consists largely of boredom. -- Zefrem Cochrane, "Metamorphosis", stardate 3219.8


devel / comp.lang.python / Parallel(?) programming with python

SubjectAuthor
* Parallel(?) programming with pythonAndreas Croci
+* Re: Parallel(?) programming with pythonStefan Ram
|+* Re: Parallel(?) programming with pythonAndreas Croci
||+* Re: Parallel(?) programming with pythonJulio Di Egidio
|||`* Re: Parallel(?) programming with pythonAndreas Croci
||| +* Re: Parallel(?) programming with pythonJulio Di Egidio
||| |`- Re: Parallel(?) programming with pythonJulio Di Egidio
||| +- RE: Parallel(?) programming with pythonDavid Raymond
||| `- Re: Parallel(?) programming with pythonDennis Lee Bieber
||`- Re: Parallel(?) programming with pythonPeter J. Holzer
|+- Re: Parallel(?) programming with pythonStefan Ram
|+- Re: Parallel(?) programming with pythonStefan Ram
|+- Re: Parallel(?) programming with pythonMRAB
|+- Re: Parallel(?) programming with pythonCameron Simpson
|`- RE: Parallel(?) programming with python<avi.e.gross
+- Re: Parallel(?) programming with pythonDennis Lee Bieber
+- Re: Parallel(?) programming with pythonLouis Krupp
+- Re: Parallel(?) programming with pythonOscar Benjamin
+- Re: Parallel(?) programming with pythonDan Stromberg
+- RE: Parallel(?) programming with pythonSchachner, Joseph (US)
+* RE: Parallel(?) programming with pythonDieter Maurer
|`* Re: Parallel(?) programming with pythonDennis Lee Bieber
| +- Re: Parallel(?) programming with pythonPeter J. Holzer
| +- Re: Parallel(?) programming with pythonsubin
| `- Re: Parallel(?) programming with pythonDieter Maurer
+- Re: Parallel(?) programming with python2QdxY4RzWzUUiLuE
+- RE: Parallel(?) programming with python<avi.e.gross
+- Re: Parallel(?) programming with pythonsubin
`- Re: Parallel(?) programming with pythonAndreas Croci

Pages:12
Parallel(?) programming with python

<tcqpju$1u59$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19145&group=comp.lang.python#19145

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!U1mfspG5k/YHtpWwp6Pb5w.user.46.165.242.91.POSTED!not-for-mail
From: andrea.c...@gmx.de (Andreas Croci)
Newsgroups: comp.lang.python
Subject: Parallel(?) programming with python
Date: Mon, 8 Aug 2022 12:47:26 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tcqpju$1u59$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="63657"; posting-host="U1mfspG5k/YHtpWwp6Pb5w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.12.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: de-DE
 by: Andreas Croci - Mon, 8 Aug 2022 10:47 UTC

tI would like to write a program, that reads from the network a fixed
amount of bytes and appends them to a list. This should happen once a
second.

Another part of the program should take the list, as it has been filled
so far, every 6 hours or so, and do some computations on the data (a FFT).

Every so often (say once a week) the list should be saved to a file,
shorthened in the front by so many items, and filled further with the
data coming fom the network. After the first saving of the whole list,
only the new part (the data that have come since the last saving) should
be appended to the file. A timestamp is in the data, so it's easy to say
what is new and what was already there.

I'm not sure how to do this properly: can I write a part of a program
that keeps doing its job (appending data to the list once every second)
while another part computes something on the data of the same list,
ignoring the new data being written?

Basically the question boils down to wether it is possible to have parts
of a program (could be functions) that keep doing their job while other
parts do something else on the same data, and what is the best way to do
this.

Re: Parallel(?) programming with python

<parallelism-20220808121750@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19146&group=comp.lang.python#19146

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: 8 Aug 2022 11:20:43 GMT
Organization: Stefan Ram
Lines: 60
Expires: 1 Apr 2023 11:59:58 GMT
Message-ID: <parallelism-20220808121750@ram.dialup.fu-berlin.de>
References: <tcqpju$1u59$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de xn5QC2S5xUy0F9jvo4/MYwky01k5GZyjAPWzuwUK1zxXWU
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Mon, 8 Aug 2022 11:20 UTC

Andreas Croci <andrea.croci@gmx.de> writes:
>Basically the question boils down to wether it is possible to have parts
>of a program (could be functions) that keep doing their job while other
>parts do something else on the same data, and what is the best way to do
>this.

Yes, but this is difficult. If you ask this question here,
you might not be ready for this.

I haven't learned it yet myself, but nevertheless tried to
write a small example program quickly, which might still
contain errors because of my lack of education.

import threading
import time

def write_to_list( list, lock, event ):
for i in range( 10 ):
lock.acquire()
try:
list.append( i )
finally:
lock.release()
event.set()
time.sleep( 3 )

def read_from_list( list, lock, event ):
while True:
event.wait()
print( "Waking up." )
event.clear()
if len( list ):
print( "List contains " + str( list[ 0 ]) + "." )
lock.acquire()
try:
del list[ 0 ]
finally:
lock.release()
else:
print( "List is empty." )

list = []
lock = threading.Lock()
event = threading.Event()
threading.Thread( target=write_to_list, args=[ list, lock, event ]).start()
threading.Thread( target=read_from_list, args=[ list, lock, event ]).start()

In basketball, first you must learn to dribble and pass,
before you can begin to shoot.

With certain reservations, texts that can be considered
to learn Python are:

"Object-Oriented Programming in Python Documentation" - a PDF file,
Introduction to Programming Using Python - Y Daniel Liang (2013),
How to Think Like a Computer Scientist - Peter Wentworth (2012-08-12),
The Coder's Apprentice - Pieter Spronck (2016-09-21), and
Python Programming - John Zelle (2009).

Re: Parallel(?) programming with python

<tcqtfg$1jro$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19147&group=comp.lang.python#19147

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!U1mfspG5k/YHtpWwp6Pb5w.user.46.165.242.91.POSTED!not-for-mail
From: andrea.c...@gmx.de (Andreas Croci)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Mon, 8 Aug 2022 13:53:20 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tcqtfg$1jro$1@gioia.aioe.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="53112"; posting-host="U1mfspG5k/YHtpWwp6Pb5w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.12.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: de-DE
 by: Andreas Croci - Mon, 8 Aug 2022 11:53 UTC

Thanks for your reply.

On 08.08.22 13:20, Stefan Ram wrote:

> Yes, but this is difficult. If you ask this question here,
> you might not be ready for this.

Indeed.

>
> I haven't learned it yet myself, but nevertheless tried to
> write a small example program quickly, which might still
> contain errors because of my lack of education.
>
> import threading
> import time
>
> def write_to_list( list, lock, event ):
> for i in range( 10 ):
> lock.acquire()
> try:
> list.append( i )
> finally:
> lock.release()
> event.set()
> time.sleep( 3 )
>
> def read_from_list( list, lock, event ):
> while True:
> event.wait()
> print( "Waking up." )
> event.clear()
> if len( list ):
> print( "List contains " + str( list[ 0 ]) + "." )
> lock.acquire()
> try:
> del list[ 0 ]
> finally:
> lock.release()
> else:
> print( "List is empty." )
>
> list = []
> lock = threading.Lock()
> event = threading.Event()
> threading.Thread( target=write_to_list, args=[ list, lock, event ]).start()
> threading.Thread( target=read_from_list, args=[ list, lock, event ]).start()

If I understand some things correctly, a "lock" would be something that,
as the name says, locks, meaning prevents parts of the program from
executing on the locked resource until ohter parts have finished doing
their things and have released the lock. If this is correct, it's not
exactly what I wanted, because this way "parts of the program" would not
"keep doing their things, while other parts do other things on the same
data".

I'm in principle ok with locks, if it must be. What I fear is that the
lock could last long and prevent the function that writes into the list
from doing so every second. With an FFT on a list that contains a few
bytes taken every second over one week time (604.800 samples), I believe
it's very likely that the FFT function takes longer than a second to return.

Then I would have to import all the data I have missed since the lock
was aquired, which is doable, but I would like to avoid it if possible.

>
> In basketball, first you must learn to dribble and pass,
> before you can begin to shoot.

Sure.

>
> With certain reservations, texts that can be considered
> to learn Python are:
>
> "Object-Oriented Programming in Python Documentation" - a PDF file,
> Introduction to Programming Using Python - Y Daniel Liang (2013),
> How to Think Like a Computer Scientist - Peter Wentworth (2012-08-12),
> The Coder's Apprentice - Pieter Spronck (2016-09-21), and
> Python Programming - John Zelle (2009).
>

Thank you for the list. I an currently taking a Udemy course and at the
same time reading the tutorials on python.org. I hope I will some day
come to any of the books you suggest (I'm doing this only in my spare
time and it will take forever).

Re: Parallel(?) programming with python

<parallelism-20220808125342@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19148&group=comp.lang.python#19148

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: 8 Aug 2022 11:54:33 GMT
Organization: Stefan Ram
Lines: 35
Expires: 1 Apr 2023 11:59:58 GMT
Message-ID: <parallelism-20220808125342@ram.dialup.fu-berlin.de>
References: <tcqpju$1u59$1@gioia.aioe.org> <parallelism-20220808121750@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de t+22Xr7nKF3gjSdfxP9+NgU5H7P8l0Z2aRPmd2llQ9Vamo
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Mon, 8 Aug 2022 11:54 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>if len( list ):
> print( "List contains " + str( list[ 0 ]) + "." )
> lock.acquire()

PS: It might be better to acquire the lock even before reading.
As I wrote, I haven't learned this yet!

There are some forms of "parallelism" one does not need threads for.

def f_():
for i in range( 10 ):
print( i )
yield

def g_():
for i in range( 65, 75 ):
print( chr( i ))
yield

print( "starting" )
f = f_()
g = g_()
try:
while True:
next( f )
next( g )
except StopIteration:
pass

And there might be other times where one wants to use
processes instead of threads. Then, there is the dreaded
"Python Global Interpreter Lock" or "GIL".

Re: Parallel(?) programming with python

<d635cf8c-41f2-4d4c-aad9-44057732314en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19150&group=comp.lang.python#19150

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a0c:df82:0:b0:474:97e5:4951 with SMTP id w2-20020a0cdf82000000b0047497e54951mr15630484qvl.96.1659963303830;
Mon, 08 Aug 2022 05:55:03 -0700 (PDT)
X-Received: by 2002:a05:6808:1247:b0:335:2987:120c with SMTP id
o7-20020a056808124700b003352987120cmr7980175oiv.142.1659963303625; Mon, 08
Aug 2022 05:55:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 8 Aug 2022 05:55:03 -0700 (PDT)
In-Reply-To: <tcqtfg$1jro$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.96.73; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.96.73
References: <tcqpju$1u59$1@gioia.aioe.org> <parallelism-20220808121750@ram.dialup.fu-berlin.de>
<tcqtfg$1jro$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d635cf8c-41f2-4d4c-aad9-44057732314en@googlegroups.com>
Subject: Re: Parallel(?) programming with python
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Mon, 08 Aug 2022 12:55:03 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 10
 by: Julio Di Egidio - Mon, 8 Aug 2022 12:55 UTC

On Monday, 8 August 2022 at 13:53:42 UTC+2, Andreas Croci wrote:

> I'm in principle ok with locks, if it must be.

Concurrent programming is quite difficult, plus you better think
in terms of queues than shared data... But, an easier and often
better option for concurrent data access is use a (relational)
database, then the appropriate transaction isolation levels
when reading and/or writing.

Julio

Re: Parallel(?) programming with python

<tcrhof$r1q$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19153&group=comp.lang.python#19153

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!U1mfspG5k/YHtpWwp6Pb5w.user.46.165.242.91.POSTED!not-for-mail
From: andrea.c...@gmx.de (Andreas Croci)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Mon, 8 Aug 2022 19:39:27 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tcrhof$r1q$1@gioia.aioe.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
<tcqtfg$1jro$1@gioia.aioe.org>
<d635cf8c-41f2-4d4c-aad9-44057732314en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="27706"; posting-host="U1mfspG5k/YHtpWwp6Pb5w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.12.0
Content-Language: de-DE
X-Notice: Filtered by postfilter v. 0.9.2
 by: Andreas Croci - Mon, 8 Aug 2022 17:39 UTC

Thank you for your reply.

On 08.08.22 14:55, Julio Di Egidio wrote:

> Concurrent programming is quite difficult, plus you better think
> in terms of queues than shared data...

Do you mean queues in the sense of deque (the data structure)? I ask
because I can see the advantage there when I try to pop data from the
front of it, but I don't see the sense of the following statement ("than
shared data"). I mean, I called my structure a list, but it may well be
a queue instead. That wouldn't prevent it from being shared in the idea
I described: one function would still append data to it while the other
is reading what is there up to a certain point and calculate the FFT of it.

But, an easier and often
> better option for concurrent data access is use a (relational)
> database, then the appropriate transaction isolation levels
> when reading and/or writing.
>

That would obviusly save some coding (but would introduce the need to
code the interaction with the database), but I'm not sure it would speed
up the thing. Would the RDBMS allow to read a table while something else
is writing to it? I doubt it and I'm not sure it doesn't flush the cache
before letting you read, which would include a normally slow disk access.

Andreas

> Julio

Re: Parallel(?) programming with python

<0fh2fhdquppev7cu2dqh0dsl5dieh970tn@4ax.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19154&group=comp.lang.python#19154

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 08 Aug 2022 17:55:02 +0000
From: wlfr...@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Mon, 08 Aug 2022 13:56:02 -0400
Organization: IISS Elusive Unicorn
Message-ID: <0fh2fhdquppev7cu2dqh0dsl5dieh970tn@4ax.com>
References: <tcqpju$1u59$1@gioia.aioe.org>
User-Agent: ForteAgent/8.00.32.1272
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 82
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-GjaRrG+i2WLnFr4DEWjA6p+Yq1JvkNfAGw/SyweTJQ4c0jlbvOZSv0F0SO+ITvQjGOJi2nc9PvJQ5/U!1qYpSWEqeqK45tWXbv8lQ/ZXw3hHo87ZlLwtWmC5mWei7Ql5lMgnvjAgdI/wphZNUY+9mabh
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 5228
 by: Dennis Lee Bieber - Mon, 8 Aug 2022 17:56 UTC

On Mon, 8 Aug 2022 12:47:26 +0200, Andreas Croci <andrea.croci@gmx.de>
declaimed the following:

>tI would like to write a program, that reads from the network a fixed
>amount of bytes and appends them to a list. This should happen once a
>second.
>

Ignoring leap seconds, there are 86400 seconds in a day -- how many
bytes are you planning to read each second?

Maybe more important? Is this a constant network connection feeding you
bytes (in which case the bytes available to read will be controlled by the
sender -- which may be sending continuously and building up a back log if
you don't empty the stream. Or are you planning to make a socket
connection, read n-bytes, close socket?

>Another part of the program should take the list, as it has been filled
>so far, every 6 hours or so, and do some computations on the data (a FFT).
>

"6 hours or so"? That leaves one open to all sorts of variable timing.
In either event, a 6 hour interval is more suited to a process started by a
cron job (Linux/Unix) or Task Scheduler (Windows). Having a thread sleep
for 6 hours means no safeguard if the parent process should die at some
point (and if you are keeping the data in an internal list, you lose all
that data too)

>Every so often (say once a week) the list should be saved to a file,

This REQUIRES the process to not fail at any point, nor any system
restarts, etc. And (see prior paragraphs) how much data are you
accumulating. In one week you have 604800 "reads". If you are reading 10
bytes each time, that makes 6MB of data you could potentially lose (on most
modern hardware, 6MB is not a memory concern... Even 32-bit OS should be
able to find space for 600MB of data...).

Much better would be to write the file as you read each chunk. If the
file is configured right, a separate process should be able to do read-only
processing of the file even while the write process is on-going. OR, you
attempt an open/write/close cycle which could be blocked while your FFT is
processing -- you'd have to detect that situation and buffer the read data
until you get a subsequent successful open, at which time you'd write all
the backlog data.

Or you could even have your FFT process copy the data to the long term
file, while the write process just starts a new file when it finds itself
blocked (and the FFT deletes the file it was reading).

>shorthened in the front by so many items, and filled further with the
>data coming fom the network. After the first saving of the whole list,
>only the new part (the data that have come since the last saving) should
>be appended to the file. A timestamp is in the data, so it's easy to say
>what is new and what was already there.
>

Personally, this sounds more suited for something like SQLite3...
Insert new records as the data is read, with timestamps. FFT process
selects records based upon last data ID (that it processed previously) to
end of new data. SQLite3 database IS the long-term storage. Might need a
second table to hold the FFT process "last data ID" so on start up it can
determine where to begin.

>I'm not sure how to do this properly: can I write a part of a program
>that keeps doing its job (appending data to the list once every second)
>while another part computes something on the data of the same list,
>ignoring the new data being written?
>
Well, if you really want ONE program -- you'll likely be looking at the
Threading module (I don't do "async", and your task doesn't seem suited for
async type call backs -- one thread that does the fetching of data, and a
second that does the FFT processing, which will be sleeping most of the
time).

But either way, I'd suggest not keeping the data in an internal list;
use some RDBM to keep the long-term data, accumulating it as you fetch it,
and letting the FFT read from the database for its processing.

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Re: Parallel(?) programming with python

<LccIK.620009$vAW9.340682@fx10.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19156&group=comp.lang.python#19156

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Subject: Re: Parallel(?) programming with python
Content-Language: en-US
Newsgroups: comp.lang.python
References: <tcqpju$1u59$1@gioia.aioe.org>
From: lkr...@invalid.pssw.com.invalid (Louis Krupp)
In-Reply-To: <tcqpju$1u59$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 59
Message-ID: <LccIK.620009$vAW9.340682@fx10.iad>
X-Complaints-To: abuse(at)newshosting.com
NNTP-Posting-Date: Mon, 08 Aug 2022 18:02:19 UTC
Organization: Newshosting.com - Highest quality at a great price! www.newshosting.com
Date: Mon, 8 Aug 2022 12:02:19 -0600
X-Received-Bytes: 3091
 by: Louis Krupp - Mon, 8 Aug 2022 18:02 UTC

On 8/8/2022 4:47 AM, Andreas Croci wrote:
> tI would like to write a program, that reads from the network a fixed
> amount of bytes and appends them to a list. This should happen once a
> second.
>
> Another part of the program should take the list, as it has been
> filled so far, every 6 hours or so, and do some computations on the
> data (a FFT).
>
> Every so often (say once a week) the list should be saved to a file,
> shorthened in the front by so many items, and filled further with the
> data coming fom the network. After the first saving of the whole list,
> only the new part (the data that have come since the last saving)
> should be appended to the file. A timestamp is in the data, so it's
> easy to say what is new and what was already there.
>
> I'm not sure how to do this properly: can I write a part of a program
> that keeps doing its job (appending data to the list once every
> second) while another part computes something on the data of the same
> list, ignoring the new data being written?
>
> Basically the question boils down to wether it is possible to have
> parts of a program (could be functions) that keep doing their job
> while other parts do something else on the same data, and what is the
> best way to do this.

You might be able to do what you need by making the file system work for
you:

Use numbered files, something like DATA/0001, DATA/0002, etc.

Start by initializing a file number variable to 1 and creating an empty
file, DATA/0001. The current time will be your start time.

In an infinite loop, just as in Stefan's example:

Read from the network and append to the current data file. This
shouldn't take long unless the file is on a remote system.

If six hours have gone by (compare the current time to the start time),
close the current date file, create a thread (see Stefan's example) to
call your FFT with the name of the current file, increment the file
number, and open a new empty data file.

If you want to, you can consolidate files every week or so. The Python
library has functions that will let you get a list files in a directory.
If you're on a Linux or UNIX system, you can use shell commands to
append, copy or rename files.

Have fun.

Louis

Re: Parallel(?) programming with python

<f673f5c3-c5b2-44aa-9f96-1fb9147bb26cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19157&group=comp.lang.python#19157

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:43d4:0:b0:6b8:e3ba:ddfc with SMTP id q203-20020a3743d4000000b006b8e3baddfcmr14672177qka.192.1659982049096;
Mon, 08 Aug 2022 11:07:29 -0700 (PDT)
X-Received: by 2002:a05:6808:1507:b0:342:cb06:8dd6 with SMTP id
u7-20020a056808150700b00342cb068dd6mr5366654oiw.284.1659982048770; Mon, 08
Aug 2022 11:07:28 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 8 Aug 2022 11:07:28 -0700 (PDT)
In-Reply-To: <tcrhof$r1q$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.96.73; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.96.73
References: <tcqpju$1u59$1@gioia.aioe.org> <parallelism-20220808121750@ram.dialup.fu-berlin.de>
<tcqtfg$1jro$1@gioia.aioe.org> <d635cf8c-41f2-4d4c-aad9-44057732314en@googlegroups.com>
<tcrhof$r1q$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f673f5c3-c5b2-44aa-9f96-1fb9147bb26cn@googlegroups.com>
Subject: Re: Parallel(?) programming with python
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Mon, 08 Aug 2022 18:07:29 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3163
 by: Julio Di Egidio - Mon, 8 Aug 2022 18:07 UTC

On Monday, 8 August 2022 at 19:39:48 UTC+2, Andreas Croci wrote:
> Thank you for your reply.
> On 08.08.22 14:55, Julio Di Egidio wrote:
>
> > Concurrent programming is quite difficult, plus you better think
> > in terms of queues than shared data...
>
> Do you mean queues in the sense of deque (the data structure)?
<snip>

No, I mean a "message queue", i.e. a synchronized queue, so that
independent components can begin/end async invocations. It
still has enqueue/dequeue, but these queues encapsulates the
needed synchronization. IOW, back to the overall picture, this is
about thinking "pipelines".

Here is just the first link I have found, but there is quite some
literature on the subject of concurrent programming and primitives:
<https://duckduckgo.com/?q=async+message+queue>

> > But, an easier and often
> > better option for concurrent data access is use a (relational)
> > database, then the appropriate transaction isolation levels
> > when reading and/or writing.
>
> That would obviusly save some coding (but would introduce the need to
> code the interaction with the database), but I'm not sure it would speed
> up the thing. Would the RDBMS allow to read a table while something else
> is writing to it? I doubt it and I'm not sure it doesn't flush the cache
> before letting you read, which would include a normally slow disk access.

An RDBMS not only does all that quite well (look up "ACID" and "transaction
isolation levels"), it also does it with an efficiency and reliability that you
would hardly be able to match in custom code, plus most RDBMS also
provide message queues and job schedulers out of the box and more.

That said, in simple scenarios all of the above might be overkill and a bit
of locking over shared data might indeed do the trick for you, just not if
you do want the reliability and performance...

Julio

Re: Parallel(?) programming with python

<6a576a1c-367d-40c6-8bd6-bdd337ac5e64n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19158&group=comp.lang.python#19158

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ad4:5c8c:0:b0:477:d19:1a44 with SMTP id o12-20020ad45c8c000000b004770d191a44mr16989624qvh.15.1659982306784;
Mon, 08 Aug 2022 11:11:46 -0700 (PDT)
X-Received: by 2002:a05:6830:4110:b0:61c:9c0f:3cba with SMTP id
w16-20020a056830411000b0061c9c0f3cbamr7299371ott.157.1659982306530; Mon, 08
Aug 2022 11:11:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 8 Aug 2022 11:11:46 -0700 (PDT)
In-Reply-To: <f673f5c3-c5b2-44aa-9f96-1fb9147bb26cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.96.73; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.96.73
References: <tcqpju$1u59$1@gioia.aioe.org> <parallelism-20220808121750@ram.dialup.fu-berlin.de>
<tcqtfg$1jro$1@gioia.aioe.org> <d635cf8c-41f2-4d4c-aad9-44057732314en@googlegroups.com>
<tcrhof$r1q$1@gioia.aioe.org> <f673f5c3-c5b2-44aa-9f96-1fb9147bb26cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6a576a1c-367d-40c6-8bd6-bdd337ac5e64n@googlegroups.com>
Subject: Re: Parallel(?) programming with python
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Mon, 08 Aug 2022 18:11:46 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1785
 by: Julio Di Egidio - Mon, 8 Aug 2022 18:11 UTC

On Monday, 8 August 2022 at 20:07:39 UTC+2, Julio Di Egidio wrote:
> On Monday, 8 August 2022 at 19:39:48 UTC+2, Andreas Croci wrote:
<snip>

> Here is just the first link I have found, but there is quite some
> literature on the subject of concurrent programming and primitives:
> <https://duckduckgo.com/?q=async+message+queue>

P.S. Sorry, I have messed up with the link, anyway that should work
as a quick starting point.

Julio

RE: Parallel(?) programming with python

<mailman.225.1659984393.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19159&group=comp.lang.python#19159

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: David.Ra...@tomtom.com (David Raymond)
Newsgroups: comp.lang.python
Subject: RE: Parallel(?) programming with python
Date: Mon, 8 Aug 2022 18:46:28 +0000
Lines: 17
Message-ID: <mailman.225.1659984393.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
<tcqtfg$1jro$1@gioia.aioe.org>
<d635cf8c-41f2-4d4c-aad9-44057732314en@googlegroups.com>
<tcrhof$r1q$1@gioia.aioe.org>
<HE1PR0701MB2857397C8DFCA9F9EFA75E3587639@HE1PR0701MB2857.eurprd07.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
X-Trace: news.uni-berlin.de l1zgV/6q3od/ierBfoEIpAAmL9xFUdT4teYxLGXVoYdw==
Return-Path: <David.Raymond@tomtom.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=tomtom.com header.i=@tomtom.com header.b=wM4GEOW7;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.022
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:python': 0.06;
'thing.': 0.07; 'concurrent': 0.09; 'writer.': 0.09; 'coding':
0.13; 'database,': 0.16; 'disk,': 0.16; 'received:40.107.21':
0.16; 'slow': 0.16; 'specify': 0.16; 'subject:programming': 0.16;
'sync': 0.16; 'it?': 0.19; 'to:addr:python-list': 0.20; 'option':
0.20; 'doubt': 0.22; 'code': 0.23; 'to:name:python-
list@python.org': 0.24; 'normally': 0.26; 'thorough': 0.26;
'else': 0.27; "doesn't": 0.32; 'but': 0.32; "i'm": 0.33; 'same':
0.34; 'header:In-Reply-To:1': 0.34; 'read': 0.38; 'use': 0.39;
'table': 0.39; 'something': 0.40; 'want': 0.40; 'including': 0.60;
'mode': 0.62; 'transaction': 0.64; 'time.': 0.66; 'time,': 0.67;
'forcing': 0.69; 'speed': 0.71; 'read,': 0.75; 'sqlite': 0.84;
'transactions': 0.84
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=fIornxebzKC8rhSPU3Ii1GBFb9PSezjtALoveIyB/OppTcikS+JCL/EMSj15ZitRATWQi4p9qXCVs4OlOf3zkVVfj3VfssBy3CgVj3pO+H5ru/G4NFsLB4I1dQXKCW5HHgsfnUoJ9l/Fn6AQfZ/E8hD4RIitadr77TGLST349wF2HeLt6/0RS9OYGVGiwNFBj3VlqmoTXFasLB8aGmxxmcQ2B98JTqyqfEvOeMNYCfVAPFeyaArdyjc4wFd+mvtkpVrWjIv/YVK4KkCpZraiuAAdRadj2WaFC6FL8ndl1ZRwwrM2U5fDoAXfszu+xYG8wYYRjSy2qPhFCHYBpZ+mjw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=FUbGM8fLjqDAuYyPgRyCqhRZFQHOtJJlIAGYlJtoroo=;
b=hQ1cLnoaTxbHDyQdvvfVMo2cFcuICw5Lu+Lg4YTQa6NFuh8KcQvzCrTF/zU9KTii8jfie2bRPWf/aLc0dZ0sQCctA5MnHATkQov8rCAAOohLIfug9u+KIS+xsz9G8MR52zfHiCP5JPB9lLVRDyWZAX7yMZycSPnT+p/+o578YS29GdzmLJPKUU9qDmhFtTqTooIGxnsaVEVqGHoO9lgsKUA2XCsaTdduDEJClxh5ysR8r8O1/kmzPHR5GBedEyfYyMpICjUY1GCwWtcForZfs69dLDT/8PvqsimeMBvo5mpoZLibt72sHSVge2epwelwmajw1PYAyq4XYTr60dfhiQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=tomtom.com; dmarc=pass action=none header.from=tomtom.com;
dkim=pass header.d=tomtom.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tomtom.com;
s=selector2;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=FUbGM8fLjqDAuYyPgRyCqhRZFQHOtJJlIAGYlJtoroo=;
b=wM4GEOW7MlaELwUxaJlc82omVLFyTIVdxjUXmVHLmL3eUsCYGU80b6T7WSaYCTLsPZIwW1rAIJ+QnrnswBX0oTfYHqeAtUMVR9gYZq9dsMf/Dt7WOI3AMYBLibh77TdYKB96NxSFqKiZgBbuirPX8mYNXpdmzO4KyhcYnsnL62w=
Thread-Topic: Parallel(?) programming with python
Thread-Index: AQHYq1Cd1p94MOhMMU6xNYvS2MukT62lS6m7gAABFIeAAAMVk4AABNUw
In-Reply-To: <tcrhof$r1q$1@gioia.aioe.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=tomtom.com;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: c70b24dd-14ec-4a0d-2063-08da796e4da2
x-ms-traffictypediagnostic: PA4PR07MB8485:EE_
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: QoREgIYSZLNFNZDORi6Y+JifPB6ck0Rh6VxJ5uUwDR3YaueXy2uY1Ec9wlkTI0uxzh9U6vvjvkqpxBfpv+vKPgD/DsGUSqXRJrDIVQxWgkRlFNz78a+odi0TPPWKePNT/rE+13oG88KD4GddXiAysmgrV2Ptx9qAikdM1b0mepDsuiR9biIrgS0OelBkW3qOOJkTlCYXgkG51innReVjkWyrEdeCNpf9RqnzhcLyuq5bet0B/rA4UJxyGnMC8ZkKcNNYWAMf5E1EvDxaQVuchryCUCMSapg/yJCTShCfJWhyzQAwEP0Uc8xK3spu+Vhu1i+HROU5zYGAcdeQyNns5SFoR45ZeJuhOZkMcwLwygJPNrLOYVXQ+yob06VmeOfW0YZY4KaCEXL0p4e0+3JCZ0aPLJ7DaRjkGE9ZjbXZMVxcle3wGLqwicwAYDvpCkLYqbQHOWIEqwdqHiFKGhE2odg4uj/DdR/9qc7xACi/6Nif2/98KuEakZiL890TAH5FrveDj0B3yh5JY9qelv0GHWxIeN/4c2Beay7dWLviJZ6ftswQ54PZleAcFYDZ+HbuqEQaoPE2vE7ZKFQbUNGW0+nA5HUrIDaRvTO+46mTooT9YeNLKVtCJE1B3bg/MkT0xkxxt9DTsin+rBVdLxct51dzcm1XSn4PRIuuNDsB6k51ceR4IKYaIAFTb8ezjQ4rZaNsjyw/x5zG8N7I48vzR00PKRYS1EL+Za0ckSBUQ3ZAQBTwghWzqhf+tfcMCuccUOaSySqCT5nDhp4ldWdU9CYmCZ7sKH4GUiWrp3UurF+6xkVbAfWxvHPNz7po+sBbe1iRZ7HTQB2o/ylC4mR6Tz+kEtbsPnQPqmePYZ4hBW8=
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:HE1PR0701MB2857.eurprd07.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230016)(4636009)(346002)(39850400004)(366004)(396003)(136003)(376002)(55016003)(26005)(478600001)(9686003)(6506007)(41300700001)(7696005)(83380400001)(8936002)(66946007)(64756008)(66556008)(66476007)(66446008)(76116006)(186003)(2906002)(5660300002)(52536014)(4744005)(71200400001)(8676002)(6916009)(316002)(122000001)(38100700002)(33656002)(86362001)(38070700005);
DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: EIgckBrpKDdiCQEhehiZl0+bO6GmEijnTEYwiNB55jM16
sbSM0cOuTFYoOnRk3PiZm/NKs+fg/m8LuD/di5XeaJEI4
fGuPpA0RNIj8tKIOCCKZF1PLVv7Q9cGjvY5f7VzXCi0Op
V5JktosSwtLT0SaeUPqP/fHXS9HpzRchw+Qgq8jxmlpCM
5RZ8DuqTl2ao1+iI7DreYVOEjOfToP8LGbi4tMR7Kvw7a
27+50fByPX4cmRjCkc8ylAjfs6yPAYXYJOCK208y5T0Ig
PdyokOVDCGhcbNNV72AKc7jKG9gEwe6UB3Ie5kO/p+Vkl
PayBJg+QIfbVWRCPfPeYFlGmCHqZHO5H+3NAm1I59hUbT
krYqEn1jQbIPdYaCA+PAIOmaiSlyufC14RQzVXpnkb/gF
LQORP0txX4ZenwLy2AHqzo7idnAPRBD2HTN/FHPagOTBT
tavSwux59vSe0SwlMnb1qROZCJrQFINai3oxjBXj4d1Xo
cr7b/qQuFjnZifQBruGTebJUpysZc0VJYApSQTjHR33eS
u00HRgM/qZ6rL1mjInSDJLYlO/cmLBL7jT4SJAnDDIfTg
pkAd9dDJxmuylugna3hf/hIAf6zG05ixm5hzNTMwt1eR4
XG6sKOqD2c70Fc5pVL7NcDxQYs+P6hQ16bsnh3Ncz6rUZ
MCOkIqIWQJeaL0WcHV95zMrtb+uApe9DK7kdkB0YIcj2T
0okDVQdUdhWRYFF4b94ppHFY25cG2yTMH1GWbLzNzPZak
tjuUIRsBb8iz73xDhfVJAfni2rDZGg/OUe040MsPmNV8S
r+cn14OKW3mXcXFOW3IVmO7hLrT6F8JARp6yBRuNbXE1z
RfEyCh/GjSqq6k/oVDI/vJccy5qxNaBjr9BsKe7/aOYBq
1vTkNl2iTIf5NG4fiLbOXQ3tl24NDwz5BJLEvJ9WwW7ff
pCMzy53X5qT49zuQdUhQRcbkkr3ltK0hqOABJHHkJrNMW
Xg1wlAV6svRsckm5im0BAHBD1+9oTpqT2mTHs0J9wpHIG
H80U8xR0hfr86QTAKKN8BxDV4hhbXlmM5powcW1Wto2WT
oZEvsNg7buPzmv82AmIMUAv8JPwiJjrh9uvOaqDlb5RGs
+q0TD+OMh9BaYGo+WxSNWeENrKx0DFQOXc4ZySks63+PW
4CSe4wG+7H7+8o6xGrYXJ/oN3faE9oXPFAa1gfnIJq5tq
idWG7GWsAWj29uOz/DuQ3Dbrgnx0JzRyQ1KjGONoM+KzJ
TFx/Z1f7CkCEJk5e2hSDmRqd98tiZsm5lpRVDFmyg6ztx
SnxuozlolbRlnpdd3AwU1hdaCCcRxjddR9l0P2VvuSkRC
/ezQSffVk19PV7UkoWjbHO5/CMPizMMHhGGEk+psP1pgC
oXBDC9j9nFRnBIzzWLVjkI9AyEdLsVwZTCCm40jIeqYDJ
u+V/2nd1j0L1ssMPSw9I2AksmiLrW75fOLtuDQDZbUEXU
l7e/9mVDb6EvlAhU9HNKlGgolhrfGKXTZKfWIdpwrplUE
Ml9TRx3IgonrPzddW65dRnqBLNyYQcXaAUurMpTrWaFk6
scuGsbX/1JU52+nkq1P3UbqJSbupb0XChsUYeGfOfPVLK
yA==
X-OriginatorOrg: tomtom.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: HE1PR0701MB2857.eurprd07.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: c70b24dd-14ec-4a0d-2063-08da796e4da2
X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2022 18:46:28.2024 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 374f8026-7b54-4a3a-b87d-328fa26ec10d
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: GdxypBoa3MvWVsFMBB9z5buvuVnaOGIy10wwKgBAYKp5yVOKpcEy8Rg9ZeS+MXDXd7Zaeb7z4uhhSjVt0mftawO7m+whKT08DMHarIwftjI=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR07MB8485
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <HE1PR0701MB2857397C8DFCA9F9EFA75E3587639@HE1PR0701MB2857.eurprd07.prod.outlook.com>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
<tcqtfg$1jro$1@gioia.aioe.org>
<d635cf8c-41f2-4d4c-aad9-44057732314en@googlegroups.com>
<tcrhof$r1q$1@gioia.aioe.org>
 by: David Raymond - Mon, 8 Aug 2022 18:46 UTC

>> But, an easier and often
>> better option for concurrent data access is use a (relational)
>> database, then the appropriate transaction isolation levels
>> when reading and/or writing.
>>
>
> That would obviusly save some coding (but would introduce the need to
> code the interaction with the database), but I'm not sure it would speed
> up the thing. Would the RDBMS allow to read a table while something else
> is writing to it? I doubt it and I'm not sure it doesn't flush the cache
> before letting you read, which would include a normally slow disk access.
SQLite for example allows only 1 write transaction at a time, but in WAL mode you can have as many read transactions as you want all going along at the same time as that 1 writer. It also allows you to specify how thorough it is in flushing data to disk, including not forcing a sync to disk at all and just leaving that to the OS to do on its own time.

Re: Parallel(?) programming with python

<multithreading-20220808195831@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19160&group=comp.lang.python#19160

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: 8 Aug 2022 18:59:46 GMT
Organization: Stefan Ram
Lines: 30
Expires: 1 Apr 2023 11:59:58 GMT
Message-ID: <multithreading-20220808195831@ram.dialup.fu-berlin.de>
References: <tcqpju$1u59$1@gioia.aioe.org> <parallelism-20220808121750@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de RoiYMY39SsPdGL4CK534tg7p14M9OLpTvLGNVBZJ9bvCNR
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Mon, 8 Aug 2022 18:59 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>Yes, but this is difficult.

Here is an excerpt from a text by Edward E. Lee
about a programing project with thread:

|A part of the Ptolemy Project experiment was to see
|whether effective software engineering practices could be
|developed for an academic research setting. We developed a
|process that included a code maturity rating system (with
|four levels, red, yellow, green, and blue), design
|reviews, code reviews, nightly builds, regression tests,
|and automated code coverage metrics [43]. The portion of
|the kernel that ensured a consistent view of the program
|structure was written in early 2000, design reviewed to
|yellow, and code reviewed to green. The reviewers included
|concurrency experts, not just inexperienced graduate
|students (Christopher Hylands (now Brooks), Bart Kienhuis,
|John Reekie, and myself were all reviewers). We wrote
|regression tests that achieved 100 percent code coverage.
|The nightly build and regression tests ran on a two
|processor SMP machine, which exhibited different thread
|behavior than the development machines, which all had a
|single processor. The Ptolemy II system itself began to be
|widely used, and every use of the system exercised this
|code. No problems were observed until the code deadlocked
|on April 26, 2004, four years later.
Edward E. Lee (2006-01-10).

Re: Parallel(?) programming with python

<mailman.227.1659986485.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19162&group=comp.lang.python#19162

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Mon, 8 Aug 2022 20:18:16 +0100
Lines: 106
Message-ID: <mailman.227.1659986485.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
<91ac042d-b3c0-72c8-e396-f1032ec6d7a0@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de ZHngF0hIfdD11dJClcSwqg9AE/FyvN22ZvfhcN4ssouA==
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=plus.com header.i=@plus.com header.b=OsUv7odM;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; 'indicate':
0.05; 'subject:python': 0.06; 'queue': 0.07; 'ram': 0.07;
'difficult.': 0.09; 'else:': 0.09; 'from:addr:python': 0.09;
'received:192.168.1.64': 0.09; 'threads': 0.09; 'writes:': 0.09;
'import': 0.15; '"in': 0.16; '"list': 0.16; 'come.': 0.16;
'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
'message-id:@mrabarnett.plus.com': 0.16; 'none:': 0.16; 'print(':
0.16; 'queues': 0.16; 'queues,': 0.16; 'received:84.93': 0.16;
'received:84.93.230': 0.16; 'received:plus.net': 0.16;
'subject:programming': 0.16; 'threading': 0.16; 'up."': 0.16;
'wrote:': 0.16; 'python': 0.16; 'to:addr:python-list': 0.20;
'list,': 0.24; 'programming': 0.25; 'tried': 0.26; 'stefan': 0.26;
'else': 0.27; 'computer': 0.29; 'header:User-Agent:1': 0.30;
'program': 0.31; 'think': 0.32; 'question': 0.32; 'here,': 0.32;
'lists,': 0.32; 'scientist': 0.32; 'received:192.168.1': 0.32;
'but': 0.32; 'same': 0.34; 'header:In-Reply-To:1': 0.34; 'item':
0.35; 'yes,': 0.35; 'errors': 0.36; 'pdf': 0.36; 'using': 0.37;
'this.': 0.37; 'received:192.168': 0.37; 'way': 0.38; 'list':
0.39; 'use': 0.39; 'break': 0.39; 'still': 0.40; 'learn': 0.40;
'something': 0.40; 'should': 0.40; 'event': 0.40; 'lack': 0.60;
'best': 0.61; 'introduction': 0.61; "there's": 0.61; 'skip:i 20':
0.62; 'data,': 0.63; 'down': 0.64; 'lock': 0.64; 'skip:t 40':
0.64; 'parts': 0.65; 'skip:t 20': 0.66; 'items': 0.68; 'pass,':
0.69; 'skip:w 20': 0.69; 'del': 0.70; '"."': 0.84; 'locking':
0.84; 'true:': 0.84; 'texts': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1659986297; bh=yEpp7kYmdQ6NcEHrU18hZ0ruztXtnT800GM0vRriPEQ=;
h=Date:Subject:To:References:From:In-Reply-To;
b=OsUv7odMn3l2SZKdaA09ryqcVcsvDM6e18WM+liNm2QfG9UD1TjtQW3QblWmH/147
kd+Ru9IsaAJsDTyFTdPuQAyKHFdUYB+me7RRCdT55OVJaXatlogRYVTOS8Smy1UfAh
f3ZeS9nZHOOz2NkKZvPfuP6AQhedz8YuOilhQSvSGqo4cjNaXuo2tXC6ks6hjza7uT
xbBjEthbA79syUMz3TaVLALZ+5i4/FY2sEcGXucHQOZ9gGFpz4gV1Ypx/IFepdLeia
ky5V5OGgCn/ylWzi+TMXTMuSQuDxD6GR13mM5d1hY0Y45sAa0s2LIolgCclCr6gXIX
tQ1yc3uLIhsQA==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=DckEF9hW c=1 sm=1 tr=0 ts=62f16179
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=uPqZvLo5dYmh-bJkHwUA:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.12.0
Content-Language: en-GB
In-Reply-To: <parallelism-20220808121750@ram.dialup.fu-berlin.de>
X-CMAE-Envelope: MS4xfBML90HbJ1HX8VGePgpWoz2rSmHn1CBS0sefJoRhq4AMnNNDQbBqnS69t1EvDSY6JkZsFGyUPmsA7amq6IznzXY55u8cIB4c7jxpOFY4A6C/O78joHHy
LtqFDoK7DZ7m/FfITsMrWKQ5N4ivTV0PL4r8MLxiL+59vtWuZAG7KP6cN+LHZ/qFjiU0wc2BhoPPXJJDWAN031ieJfz3VR89LPs=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <91ac042d-b3c0-72c8-e396-f1032ec6d7a0@mrabarnett.plus.com>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
 by: MRAB - Mon, 8 Aug 2022 19:18 UTC

On 2022-08-08 12:20, Stefan Ram wrote:
> Andreas Croci <andrea.croci@gmx.de> writes:
>>Basically the question boils down to wether it is possible to have parts
>>of a program (could be functions) that keep doing their job while other
>>parts do something else on the same data, and what is the best way to do
>>this.
>
> Yes, but this is difficult. If you ask this question here,
> you might not be ready for this.
>
> I haven't learned it yet myself, but nevertheless tried to
> write a small example program quickly, which might still
> contain errors because of my lack of education.
>
> import threading
> import time
>
> def write_to_list( list, lock, event ):
> for i in range( 10 ):
> lock.acquire()
> try:
> list.append( i )
> finally:
> lock.release()
> event.set()
> time.sleep( 3 )
>
> def read_from_list( list, lock, event ):
> while True:
> event.wait()
> print( "Waking up." )
> event.clear()
> if len( list ):
> print( "List contains " + str( list[ 0 ]) + "." )
> lock.acquire()
> try:
> del list[ 0 ]
> finally:
> lock.release()
> else:
> print( "List is empty." )
>
> list = []
> lock = threading.Lock()
> event = threading.Event()
> threading.Thread( target=write_to_list, args=[ list, lock, event ]).start()
> threading.Thread( target=read_from_list, args=[ list, lock, event ]).start()
>
> In basketball, first you must learn to dribble and pass,
> before you can begin to shoot.
>
> With certain reservations, texts that can be considered
> to learn Python are:
>
> "Object-Oriented Programming in Python Documentation" - a PDF file,
> Introduction to Programming Using Python - Y Daniel Liang (2013),
> How to Think Like a Computer Scientist - Peter Wentworth (2012-08-12),
> The Coder's Apprentice - Pieter Spronck (2016-09-21), and
> Python Programming - John Zelle (2009).
>
When working with threads, you should use queues, not lists, because
queues do their own locking and can wait for items to arrive, with a
timeout, if desired:

import queue
import threading
import time

def write_to_item_queue(item_queue):
for i in range(10):
print("Put", i, "in queue.", flush=True)
item_queue.put(i)
time.sleep(3)

# Using None to indicate that there's no more to come.
item_queue.put(None)

def read_from_item_queue(item_queue):
while True:
try:
item = item_queue.get()
except item_queue.Empty:
print("Queue is empty; should've have got here!", flush=True)
else:
print("Queue contains " + str(item) + ".", flush=True)

if item is None:
# Using None to indicate that there's no more to come.
break

item_queue = queue.Queue()

write_thread = threading.Thread(target=write_to_item_queue,
args=[item_queue])
write_thread.start()

read_thread = threading.Thread(target=read_from_item_queue,
args=[item_queue])
read_thread.start()

# Wait for the threads to finish.
write_thread.join()
read_thread.join()

print("Finished.")

Re: Parallel(?) programming with python

<mailman.229.1659993365.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19164&group=comp.lang.python#19164

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: hjp-pyt...@hjp.at (Peter J. Holzer)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Mon, 8 Aug 2022 23:09:27 +0200
Lines: 57
Message-ID: <mailman.229.1659993365.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
<tcqtfg$1jro$1@gioia.aioe.org>
<20220808210927.3f3zbwuonptbtazm@hjp.at>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="562wr4we4gwrxilq"
X-Trace: news.uni-berlin.de cxzTPbGLtWHXf2bYRAWp6woxs4l81aiOW7SwTz9PANNg==
Return-Path: <hjp-python@hjp.at>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'content-
type:multipart/signed': 0.05; 'math': 0.05; 'programming.': 0.05;
'subject:python': 0.06; 'performing': 0.07; 'python.': 0.08;
'computing': 0.09; 'content-type:application/pgp-signature': 0.09;
'filename:fname piece:asc': 0.09; 'filename:fname
piece:signature': 0.09; 'filename:fname:signature.asc': 0.09;
'numpy': 0.09; 'python)': 0.09; 'threads': 0.09; '"creative':
0.16; '+0200,': 0.16; '__/': 0.16; 'challenge!"': 0.16;
'computation': 0.16; 'cpython': 0.16; 'from:addr:hjp-python':
0.16; 'from:addr:hjp.at': 0.16; 'from:name:peter j. holzer': 0.16;
'hjp@hjp.at': 0.16; 'holzer': 0.16; 'instruction.': 0.16;
'interpreter': 0.16; 'locks': 0.16; 'manipulating': 0.16;
'reality.': 0.16; 'stross,': 0.16; 'subject:programming': 0.16;
'url-ip:212.17.106.137/32': 0.16; 'url-ip:212.17.106/24': 0.16;
'url-ip:212.17/16': 0.16; 'url:hjp': 0.16; 'writes': 0.16;
'|_|_)': 0.16; 'wrote:': 0.16; 'python': 0.16; "can't": 0.17;
'to:addr:python-list': 0.20; 'written': 0.22; 'anything': 0.25;
'function': 0.27; 'sense': 0.28; 'packages': 0.31; 'takes': 0.31;
'said,': 0.32; "i'm": 0.33; 'release': 0.34; 'same': 0.34; 'header
:In-Reply-To:1': 0.34; "it's": 0.37; 'others': 0.37; 'could':
0.38; 'two': 0.39; 'least': 0.39; 'single': 0.39; 'list': 0.39;
'shared': 0.39; 'reference': 0.60; 'likely': 0.61; 'week': 0.61;
'received:212': 0.62; 'lock': 0.64; 'received:userid': 0.66;
'prevent': 0.67; 'ps:': 0.69; 'url-ip:212/8': 0.69; 'longer':
0.71; 'global': 0.73; 'received:at': 0.84; 'return.': 0.91
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <tcqtfg$1jro$1@gioia.aioe.org>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <20220808210927.3f3zbwuonptbtazm@hjp.at>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
<tcqtfg$1jro$1@gioia.aioe.org>
 by: Peter J. Holzer - Mon, 8 Aug 2022 21:09 UTC
Attachments: signature.asc (application/pgp-signature)

On 2022-08-08 13:53:20 +0200, Andreas Croci wrote:
> I'm in principle ok with locks, if it must be. What I fear is that the lock
> could last long and prevent the function that writes into the list from
> doing so every second. With an FFT on a list that contains a few bytes taken
> every second over one week time (604.800 samples), I believe it's very
> likely that the FFT function takes longer than a second to return.

You woudn't lock the part performing the FFT, of course, only the part
manipulating the shared list.

That said, CPython (the reference implementation of Python) has what is
called the Global Interpreter Lock (GIL) which locks every single Python
instruction. So you can't have two threads actually computing anything
at the same time - at least not if the computation is written in Python.
Math packages like Numpy may or may not release the lock while they are
busy.

hp

PS: I also agree with what others have said about the perils of
multi-threaded programming.

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

Attachments: signature.asc (application/pgp-signature)
Re: Parallel(?) programming with python

<mailman.230.1659998265.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19165&group=comp.lang.python#19165

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs...@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Tue, 9 Aug 2022 08:37:34 +1000
Lines: 30
Message-ID: <mailman.230.1659998265.20444.python-list@python.org>
References: <parallelism-20220808121750@ram.dialup.fu-berlin.de>
<YvGQLrV7lhywpp6M@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de EnUx7m8spxQrv6eCUHj4aAZWTZiMqfaS4XPCee8IreJQ==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:python': 0.06;
'ram': 0.07; 'concurrent': 0.09; 'difficult.': 0.09; 'skip:` 10':
0.09; 'writes:': 0.09; 'cheers,': 0.11; '"standard"': 0.16;
'cameron': 0.16; 'from:addr:cs': 0.16; 'from:addr:cskk.id.au':
0.16; 'from:name:cameron simpson': 0.16; 'message-
id:@cskk.homeip.net': 0.16; 'received:13.237': 0.16;
'received:13.237.201': 0.16; 'received:13.237.201.189': 0.16;
'received:cskk.id.au': 0.16; 'received:id.au': 0.16;
'received:mail.cskk.id.au': 0.16; 'simpson': 0.16;
'subject:programming': 0.16; 'wrote:': 0.16; 'to:addr:python-
list': 0.20; 'stefan': 0.26; 'else': 0.27; 'header:User-Agent:1':
0.30; 'approach': 0.31; 'program': 0.31; 'question': 0.32;
'context': 0.32; 'here,': 0.32; 'objects': 0.32; 'but': 0.32;
'same': 0.34; 'header:In-Reply-To:1': 0.34; 'received:au': 0.35;
'yes,': 0.35; 'this.': 0.37; 'way': 0.38; 'something': 0.40;
'best': 0.61; 'data,': 0.63; 'down': 0.64; 'activity': 0.64;
'lock': 0.64; 'received:13': 0.64; 'requirement': 0.64; 'parts':
0.65; 'received:userid': 0.66; 'need.': 0.84; 'so:': 0.84
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <parallelism-20220808121750@ram.dialup.fu-berlin.de>
User-Agent: Mutt/2.2.3 (2022-04-12)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YvGQLrV7lhywpp6M@cskk.homeip.net>
X-Mailman-Original-References: <parallelism-20220808121750@ram.dialup.fu-berlin.de>
 by: Cameron Simpson - Mon, 8 Aug 2022 22:37 UTC

On 08Aug2022 11:20, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>Andreas Croci <andrea.croci@gmx.de> writes:
>>Basically the question boils down to wether it is possible to have parts
>>of a program (could be functions) that keep doing their job while other
>>parts do something else on the same data, and what is the best way to do
>>this.
>
> Yes, but this is difficult. If you ask this question here,
> you might not be ready for this.

This is a very standard requirement for any concurrent activity and the
typical approach is a mutex (mutual exclusion). You've already hit on
the "standard" approach: a `threading.Lock` object.

> lock.acquire()
> try:
> list.append( i )
> finally:
> lock.release()

Small note, which makes writing this much clearer. Lock objects are
context managers. So:

with lock:
list.append(i)

is all you need.

Cheers,
Cameron Simpson <cs@cskk.id.au>

Re: Parallel(?) programming with python

<mailman.231.1660000945.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19166&group=comp.lang.python#19166

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: oscar.j....@gmail.com (Oscar Benjamin)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Tue, 9 Aug 2022 00:22:12 +0100
Lines: 39
Message-ID: <mailman.231.1660000945.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<CAHVvXxTbmaLZnRg1O25nXb+TKvAg24HsV9YjYBra50q14Gr_pQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 90pTisfppCf8ouKT0/qgAgmfmduOEnmdL/YNn4SXPmgw==
Return-Path: <oscar.j.benjamin@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=KeybgL9j;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.014
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '2022': 0.05; 'network.':
0.05; 'parallel': 0.05; 'subject:python': 0.06; 'aug': 0.07;
'filled': 0.09; 'threads': 0.09; 'appended': 0.16; 'computations':
0.16; 'far,': 0.16; 'items,': 0.16; 'locks': 0.16; 'program"':
0.16; 'subject:programming': 0.16; 'writes': 0.16; 'wrote:': 0.16;
'problem': 0.16; 'to:addr:python-list': 0.20; 'basically': 0.22;
'list,': 0.24; 'else': 0.27; 'coming': 0.27; 'done': 0.28; 'etc':
0.28; 'whole': 0.30; 'program,': 0.31; 'saved': 0.31; 'program':
0.31; 'question': 0.32; 'message-id:@mail.gmail.com': 0.32; "i'm":
0.33; 'same': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'mon,':
0.36; 'posts': 0.36; "it's": 0.37; 'received:209.85': 0.37;
'this.': 0.37; 'file': 0.38; 'way': 0.38; 'received:209': 0.39;
'two': 0.39; 'list': 0.39; 'happen': 0.40; 'program.': 0.40;
'something': 0.40; 'should': 0.40; 'best': 0.61; 'come': 0.62;
'data,': 0.63; 'hours': 0.63; 'once': 0.63; 'down': 0.64;
'becomes': 0.64; 'parts': 0.65; 'further': 0.69; 'complexity':
0.69; 'front': 0.70; 'easy': 0.74; 'supposed': 0.76; 'oscar': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc; bh=mmr0dkcHiXxbtRXoJvfftu7CMyOXsCuySWYROlqWzi4=;
b=KeybgL9j+NsJttnjRukrleREFxbWc+WGPLtpbVFp9otoEBmEEn8bjFsJS0erm0WvPi
IF5wseLxcM+fsoTmpYkiQOpW1jOL/FwYIJjSDKELFuK/9DBlWj4Ef3nnV4OFWel7r7ZC
6+RuYiwq8V6TVgaaCTatcCzoh/O+60wACWZEktDiAqtDdNRkIIaoionceiTY9oFPwPlg
CagMw+dL9p184pI3nxk+ho/bqPgNoQ75KXxwLLCoMdSKg2Ip/FUIpKK+StKxLwJh0b7p
aIEkcxwTPL93wmhAkIKtPAgaq+YfFGJYXc2wPu0Ys5qphShsRhES98CUeD/1uO7G+/mq
qbGw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc;
bh=mmr0dkcHiXxbtRXoJvfftu7CMyOXsCuySWYROlqWzi4=;
b=kftPY9yHBctFH5cQDYK5uBm7laOrpD+4hp3SZeI2s4cf0c1rL4xr/ovVMGQzJ7LXMv
u7ueGNsBSa1jWw19X3QPvNwzbtxB+4w1AW7/bznSJdl2Rwz+KRdtmyq81qz5uw2rzi5A
o+DRhB4er9D07T6YOt3M9HzlBTaTlwT49Ul/HbYBLEvbWp4U2NYV0ZR9v89C6yDQux6W
+DgKe+loHKYiCP20djU8rHBxBkJ/v6Olf/0JbZDjvi9qA1oSGqu53HUbJckwFgJ5Lul+
wgW4uQiSgzh/6ZuhHMIw80xM+t0z/qKJjNGrv10vKIvmfos9T5j5dcsu0iQuiEKQfnc8
876w==
X-Gm-Message-State: ACgBeo0TnfxU2/hYMKjvklNrrqr7GtwjJr+r6x036vJrxH55jhApT7A0
HCxOkZj52ofWGmEHXfqpLGsdJEo+D5faSwkqX0+ZNWQ3
X-Google-Smtp-Source: AA6agR7eeHhe7W5JELe/yWYIXgJwgJW06RNLt5rk6YTT3D0de1DBjyjPxjm3mSHgd4IBHJCj7F/x53Xpnlz0hiLg5EI=
X-Received: by 2002:a05:6512:12c7:b0:48b:3bc4:10f4 with SMTP id
p7-20020a05651212c700b0048b3bc410f4mr5792255lfg.411.1660000943303; Mon, 08
Aug 2022 16:22:23 -0700 (PDT)
In-Reply-To: <tcqpju$1u59$1@gioia.aioe.org>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAHVvXxTbmaLZnRg1O25nXb+TKvAg24HsV9YjYBra50q14Gr_pQ@mail.gmail.com>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
 by: Oscar Benjamin - Mon, 8 Aug 2022 23:22 UTC

On Mon, 8 Aug 2022 at 19:01, Andreas Croci <andrea.croci@gmx.de> wrote:
>
> tI would like to write a program, that reads from the network a fixed
> amount of bytes and appends them to a list. This should happen once a
> second.
>
> Another part of the program should take the list, as it has been filled
> so far, every 6 hours or so, and do some computations on the data (a FFT).
>
> Every so often (say once a week) the list should be saved to a file,
> shorthened in the front by so many items, and filled further with the
> data coming fom the network. After the first saving of the whole list,
> only the new part (the data that have come since the last saving) should
> be appended to the file. A timestamp is in the data, so it's easy to say
> what is new and what was already there.
>
> I'm not sure how to do this properly: can I write a part of a program
> that keeps doing its job (appending data to the list once every second)
> while another part computes something on the data of the same list,
> ignoring the new data being written?
>
> Basically the question boils down to wether it is possible to have parts
> of a program (could be functions) that keep doing their job while other
> parts do something else on the same data, and what is the best way to do
> this.

Why do these "parts of a program" need to be part of the *same*
program. I would write this as just two separate programs. One
collects the data and writes it to a file. The other periodically
reads the file and computes the DFT.

Note that a lot of the complexity discussed in other posts to do with
threads and locks etc comes from the supposed constraint that this
needs to be done with threads or something else that can work in
parallel *within the same program*. If you relax that constraint the
problem becomes a lot simpler.

--
Oscar

RE: Parallel(?) programming with python

<mailman.232.1660002623.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19167&group=comp.lang.python#19167

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: Parallel(?) programming with python
Date: Mon, 8 Aug 2022 19:50:13 -0400
Lines: 104
Message-ID: <mailman.232.1660002623.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
<00ab01d8ab81$9b36cb60$d1a46220$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de TxbBD+SIRlmsf7ZVURLOKwrTBI9ysebyel2mtQrnRnhA==
Return-Path: <avi.e.gross@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=jctPqNL/;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.007
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; '2022': 0.05;
'variable': 0.05; 'subject:python': 0.06; 'moment,': 0.07; 'ram':
0.07; 'difficult.': 0.09; 'else:': 0.09; 'ideas.': 0.09; 'other.':
0.09; 'rarely': 0.09; 'received:209.85.219': 0.09; 'worker': 0.09;
'writes:': 0.09; 'import': 0.15; 'url:mailman': 0.15; 'possible,':
0.15; '"list': 0.16; 'constantly': 0.16; 'hours,': 0.16; 'lock.':
0.16; 'locks': 0.16; 'print(': 0.16; 'subject:programming': 0.16;
'threading': 0.16; 'up."': 0.16; 'whatever.': 0.16; 'python':
0.16; 'message-id:@gmail.com': 0.18; 'to:addr:python-list': 0.20;
'code': 0.23; 'goal': 0.23; 'list,': 0.24; 'skip:- 10': 0.25;
'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'programming': 0.25; 'url-ip:188.166/16':
0.25; 'tried': 0.26; 'notes': 0.26; 'so.': 0.26; 'stefan': 0.26;
'else': 0.27; 'bit': 0.27; 'example,': 0.28; 'computer': 0.29;
'url-ip:188/8': 0.31; 'program': 0.31; 'think': 0.32; 'question':
0.32; 'empty': 0.32; 'here,': 0.32; 'python-list': 0.32;
'scientist': 0.32; 'structure': 0.32; 'but': 0.32; 'there': 0.33;
'release': 0.34; 'same': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'complex': 0.35; 'yes,': 0.35;
'from:addr:gmail.com': 0.35; 'errors': 0.36; 'pdf': 0.36;
'processes': 0.36; 'using': 0.37; 'received:209.85': 0.37;
'this.': 0.37; 'received:209': 0.39; 'two': 0.39; 'adding': 0.39;
'single': 0.39; 'list': 0.39; 'received:100': 0.39; 'still': 0.40;
'learn': 0.40; 'something': 0.40; 'want': 0.40; 'should': 0.40;
'event': 0.40; 'lack': 0.60; 'best': 0.61; 'introduction': 0.61;
'above': 0.62; 'from:': 0.62; 'to:': 0.62; 'data,': 0.63; 'hours':
0.63; 'share': 0.63; 'down': 0.64; 'lock': 0.64; 're:': 0.64;
'your': 0.64; 'parts': 0.65; 'six': 0.65; 'let': 0.66; 'skip:t
20': 0.66; 'time.': 0.66; 'exactly': 0.68; 'pass,': 0.69;
'within': 0.69; 'del': 0.70; 'instead,': 0.70; 'sent:': 0.78;
'quickly': 0.80; 'position': 0.81; '"."': 0.84; 'true:': 0.84;
'expensive.': 0.91; 'texts': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc; bh=2/yzJpcFDwpTiAIOXjCeRyzTrdBPrtvaG40E56fkK50=;
b=jctPqNL/YoV4a4rT7PQWRGxgTfdZCuFj7e5dgqibiKqt/E2Xakf4fyVeAES4HpxxFI
s49dtGUS/pEJKpivUvWYn0LlEQhx0SvJje5gKcyhzGLGi1N/5TGktEuDoNjkNTbB8Xeg
rBgU+HC7fr8VttCT79j8FhI+NijVIJ+MAfluw1zQUsn6Ff8PP1G639eKu4w1d4OrEKsB
3RlLxBXyftfmy73mDBcS29ZVBske5V9x9atUch2oo7ekXYgUnLYw/1d/Tq/U45uS9woW
GiZ3GPQaIHU1jwYOBkRRKb3IqiBBNem+EyAKXA7rTvgM+IpQuzVndVwb3/YbhQc75H++
Tfsw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc;
bh=2/yzJpcFDwpTiAIOXjCeRyzTrdBPrtvaG40E56fkK50=;
b=7LOUaUNgrRFw+hyyBkFc+qnWCEcln2qQIPO9qe8Crwo71lU6sDjvAXN/B16iz/kUKv
Yi5IjzQvfDKVAwxxOEGzW7DI1Urn42F1D3rtRG8yy4VWiJYc2F76WSSqPy5ft7tnsOKo
jzWiKmMBi12/GftOPiClQdoYQezvtb6Q8DAtZuK4s0pmzE+NK0nkCqlJ2WHrJogFxCAd
qP0yz7KlwenblVnDuSNmyZKuGhagVfJSFjRHAnWMUCfOxZTwkiv6a3Rs4sv6dp33gBG5
Gqep5z8m/nZy9A3C6eDMvuXlb/mkpRKnbVMgsON84XFlN01HblPHlJdiFSwB1Dxb5Ub1
bhvA==
X-Gm-Message-State: ACgBeo37tyBWuruNhnbEUYHHlqIDbYaPQ1QVXI50z0cotwqMNuor93uo
6w84x8ZQ33uAViMdtL8a2fuCc2Lk1Rc=
X-Google-Smtp-Source: AA6agR4dXU6mgT0G8NvrxGOBCLnKLs9uTJGFNbGI9CKaqdUNbXfwT206LAyWr8uhO4e9L7ClS8tPBQ==
X-Received: by 2002:a05:6214:f61:b0:475:69c3:734f with SMTP id
iy1-20020a0562140f6100b0047569c3734fmr17844507qvb.84.1660002621130;
Mon, 08 Aug 2022 16:50:21 -0700 (PDT)
In-Reply-To: <parallelism-20220808121750@ram.dialup.fu-berlin.de>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQGIaoHVJxGa2SnrkgPY2vGzOeJjGwHemUrErjc2StA=
Content-Language: en-us
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <00ab01d8ab81$9b36cb60$d1a46220$@gmail.com>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
<parallelism-20220808121750@ram.dialup.fu-berlin.de>
 by: - Mon, 8 Aug 2022 23:50 UTC

Stefan,

You are correct that the goal of a lock is to do something rather quickly
and atomically, so your design should not do something complex or long
before releasing the lock.

In your example, you have a producer adding data as regularly as every
second and another that wakes up rarely and processes all the data since the
last time. So you may want to augment the code you had to do something fast
like point another variable at the data gathered so far and move the
original variable to an empty list or whatever. Then you release the lock
within fractions of a second and let the regular job keep adding to the
initially empty list while the other part of the code processes without a
lock.

A design like the above has the busy worker constantly checking the lock. An
alternative if you are sure the other process will only show up almost
exactly at 6 hours on the clock, is to have the busy one check the time
instead, but that may be more expensive.

Still other architectures are possible, such as writing to not a single list
for six hours, but some data structure with multiple sub-lists such as one
where you switch every minute or so. The second process can note how many
entries there are at the moment, and does all but the last and notes the
location so the next time it starts there. This would work if you did not
need every last bit of data as the two do not interfere with each other. And
no real locks would be needed as the only thing the two parts share is the
position or identity of the current last fragment which only one process
actually touches.

Just some ideas. Lots of other variations are very possible.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Stefan Ram
Sent: Monday, August 8, 2022 7:21 AM
To: python-list@python.org
Subject: Re: Parallel(?) programming with python

Andreas Croci <andrea.croci@gmx.de> writes:
>Basically the question boils down to wether it is possible to have
>parts of a program (could be functions) that keep doing their job while
>other parts do something else on the same data, and what is the best
>way to do this.

Yes, but this is difficult. If you ask this question here,
you might not be ready for this.

I haven't learned it yet myself, but nevertheless tried to
write a small example program quickly, which might still
contain errors because of my lack of education.

import threading
import time

def write_to_list( list, lock, event ):
for i in range( 10 ):
lock.acquire()
try:
list.append( i )
finally:
lock.release()
event.set()
time.sleep( 3 )

def read_from_list( list, lock, event ):
while True:
event.wait()
print( "Waking up." )
event.clear()
if len( list ):
print( "List contains " + str( list[ 0 ]) + "." )
lock.acquire()
try:
del list[ 0 ]
finally:
lock.release()
else:
print( "List is empty." )

list = []
lock = threading.Lock()
event = threading.Event()
threading.Thread( target=write_to_list, args=[ list, lock, event ]).start()
threading.Thread( target=read_from_list, args=[ list, lock, event ]).start()

In basketball, first you must learn to dribble and pass,
before you can begin to shoot.

With certain reservations, texts that can be considered
to learn Python are:

"Object-Oriented Programming in Python Documentation" - a PDF file,
Introduction to Programming Using Python - Y Daniel Liang (2013), How to
Think Like a Computer Scientist - Peter Wentworth (2012-08-12), The Coder's
Apprentice - Pieter Spronck (2016-09-21), and Python Programming - John
Zelle (2009).

--
https://mail.python.org/mailman/listinfo/python-list

Re: Parallel(?) programming with python

<6ua3fhlps6l1pk1akakj5d93i942vua8so@4ax.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19168&group=comp.lang.python#19168

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 09 Aug 2022 00:49:19 +0000
From: wlfr...@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Mon, 08 Aug 2022 20:50:17 -0400
Organization: IISS Elusive Unicorn
Message-ID: <6ua3fhlps6l1pk1akakj5d93i942vua8so@4ax.com>
References: <tcqpju$1u59$1@gioia.aioe.org> <parallelism-20220808121750@ram.dialup.fu-berlin.de> <tcqtfg$1jro$1@gioia.aioe.org> <d635cf8c-41f2-4d4c-aad9-44057732314en@googlegroups.com> <tcrhof$r1q$1@gioia.aioe.org>
User-Agent: ForteAgent/8.00.32.1272
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 48
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-M2Fsla6l+KZa3qMSTPcDhtym+0sLj7mBiHIi+vcgFCbLtvloztZN1BvulDeo0QrnyLa2zS0TgZmupbi!/A4hEebwqDerWEB6UyyKKTCILHeFptVw93Xw2XEbBO6q03JVzzgK5sfw1BSf2rcLklMbnypy
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Dennis Lee Bieber - Tue, 9 Aug 2022 00:50 UTC

On Mon, 8 Aug 2022 19:39:27 +0200, Andreas Croci <andrea.croci@gmx.de>
declaimed the following:

>
>Do you mean queues in the sense of deque (the data structure)? I ask
>because I can see the advantage there when I try to pop data from the
>front of it, but I don't see the sense of the following statement ("than

Most likely this was a reference to the Queue module -- which is used
to pass data from one thread to another. Your "fetch" thread would package
up the "new" data to be processed by the FFT thread. The FFT thread is
blocked waiting for data to appear on the queue -- when it appears, the FFT
thread reads the entire packet of data and proceeds to process it.

Note that in this scheme, the FFT thread is NOT on a timer -- the fetch
thread controls the timing by when it puts data into the queue.

cf:
https://docs.python.org/3/library/threading.html
https://docs.python.org/3/library/queue.html

>
>That would obviusly save some coding (but would introduce the need to
>code the interaction with the database), but I'm not sure it would speed
>up the thing. Would the RDBMS allow to read a table while something else
>is writing to it? I doubt it and I'm not sure it doesn't flush the cache
>before letting you read, which would include a normally slow disk access.
>

Depends upon the RDBMs. Some are "multi-version concurrency" -- they
snapshot the data at the time of the read, while letting new writes
proceed. But if one is doing read/modify/write, this can cause a problem as
the RDBM will detect that a record was modified by someone else and prevent
you from changing it -- you have to reselect the data to get the current
version.

You will want to treat each of your network fetches as a transaction --
and close the transaction fast. Your FFT process would need to select all
data in the range to be processed, and load it into memory so you can free
that transaction

https://www.sqlite.org/lockingv3.html See section 3.0 and section 5.0

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Re: Parallel(?) programming with python

<mailman.234.1660016632.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19170&group=comp.lang.python#19170

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: drsali...@gmail.com (Dan Stromberg)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Mon, 8 Aug 2022 20:43:37 -0700
Lines: 32
Message-ID: <mailman.234.1660016632.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<CAGGBd_pMw_JBtbDA1VKP9KcHNGRUn6HibGdbEBMA_hhTGG=dRQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de JimyIOqT2XX6hjtlsjiF+gSnvaywAKAPx1PlXtB4BrqQ==
Return-Path: <drsalists@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=PiaflstG;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2022': 0.05;
'subject:python': 0.06; 'aug': 0.07; 'cc:addr:python-list': 0.09;
'implicit': 0.09; 'threads': 0.09; 'cc:name:python list': 0.16;
'cpython': 0.16; 'cpython,': 0.16; 'directly,': 0.16;
'from:addr:drsalists': 0.16; 'from:name:dan stromberg': 0.16;
'kind,': 0.16; 'loops': 0.16; 'micropython': 0.16; 'processes.':
0.16; 'queues': 0.16; 'relatively': 0.16; 'sadly,': 0.16;
'smoothly.': 0.16; 'subject:programming': 0.16; 'tedious': 0.16;
'tends': 0.16; 'threading': 0.16; 'wrote:': 0.16; 'probably':
0.17; 'cc:addr:python.org': 0.20; 'code': 0.23; 'run': 0.23;
'python,': 0.25; 'cc:2**0': 0.25; 'suggest': 0.28; 'program,':
0.31; 'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'same':
0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'mon,': 0.36; 'lists': 0.37; 'using':
0.37; 'received:209.85': 0.37; 'could': 0.38; '8bit%:14': 0.38;
'received:209': 0.39; 'use': 0.39; 'decide': 0.39; 'rest': 0.39;
'appears': 0.40; 'happen': 0.40; 'otherwise,': 0.40; 'should':
0.40; 'likely': 0.61; 'gives': 0.62; 'once': 0.63; 'between':
0.63; 'your': 0.64; 'less': 0.65; 'time.': 0.66; 'right': 0.68;
'easy': 0.74; 'scalable': 0.76; 'switching': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=Jhh8W1b1A8Uuhf7qbNc593Zzm+Zz0CM4obDWnoo9HPs=;
b=PiaflstGFSMQrRL3NGtPojUR1ld8F5pMqKQ5QuDGgPHnoGfxKKzUGSzAj0YkmBFQWM
dNCK3XYIpd4sca3f/Cf0IIxQSh0ceUCkl5c15n0rZBunHIwA0khbmitUDAHTa0PTupnX
fTbWJq7W7my3UhmuKCXXd5B+jS7db9d5xoYy0HyHqFXNwg9SQ9olBbqQMqaJXFsKO2mi
EkyOfVgAMH3yMC1xhUkK9nFfZ20xNWRgh28q4VwIVgYMw/aIJ3Mg1IMexthczdcsk3FV
DnO6YgMYw489R4g5iVpGBsQ9dfsBT4a5xZ+pxxqXE+yr0+iMPdnB2JaVuZTOXer37YvQ
Uc1w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=Jhh8W1b1A8Uuhf7qbNc593Zzm+Zz0CM4obDWnoo9HPs=;
b=7iPVsHhKFna2iw25DAViTPCBs/5Az6tUDmXME61N/qR1ytdwJM6bNyA1zddoJpbzuC
haKsqwTgR33o6JEo8OZHzpi+Y/Z4anZ+wJDVejfEf+Y0wF6NWS5HY87QK93F/w32m4kd
1U+QLdR5hYyCNNpnisRuIouI6tstzZdXBjvWdTtoZuCHTPL9LkrGr6vnFkDHGNmpBXnu
GnmYKGM+zJiN31saNeySHe3Qntdwftd8ONHQFD0NrqEzfvDMH6bDs23vSBsItOtVqchv
TtOXF+e4yUIDCWerLnyD3hJ3z+Mzspp4bbvxQaTWyXE3nshLDJlouYPfIc8zoPAuMwNz
7Ktg==
X-Gm-Message-State: ACgBeo2Gw701YOc6LgSwlw9qdcoJ7eSsj/JKD8sinvrMMuM6wCw5LWYD
JOnpFYxRTntKnxJj5v6N0AVGjw1eRq0IRC/dbJg=
X-Google-Smtp-Source: AA6agR69v1YxAIMOinl9fF3yMtMNSsAljOWn0d98slE1/15otNRUM4oVYyAjrAzhreoRk/TpG9Ah55YfNzBh9E103NI=
X-Received: by 2002:a05:6512:324b:b0:48b:1d7d:6874 with SMTP id
c11-20020a056512324b00b0048b1d7d6874mr6944852lfr.18.1660016629710; Mon, 08
Aug 2022 20:43:49 -0700 (PDT)
In-Reply-To: <tcqpju$1u59$1@gioia.aioe.org>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAGGBd_pMw_JBtbDA1VKP9KcHNGRUn6HibGdbEBMA_hhTGG=dRQ@mail.gmail.com>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
 by: Dan Stromberg - Tue, 9 Aug 2022 03:43 UTC

Queues are better than lists for concurrency. If you get the right kind,
they have implicit locking, making your code simpler and more robust at the
same time.

CPython threading is mediocre for software systems that have one or more
CPU-bound threads, and your FFT might be CPU-bound.

Rather than using threading directly, you probably should use
https://docs.python.org/3/library/concurrent.futures.html , which gives you
easy switching between threads and processes.

Or if you, like me, get inordinately joyous over programs that run on more
than one kind of Python, you could give up concurrent.futures and use
_thread. Sadly, that gives up easy flipping between threads and processes,
but gives you easy flipping between CPython and micropython. Better still,
micropython appears to have more scalable threading than CPython, so if you
decide you need 20 CPU-hungry threads someday, you are less likely to be in
a bind.

For reading from a socket, if you're not going the REST route, may I
suggest https://stromberg.dnsalias.org/~strombrg/bufsock.html ? It deals
with framing and lengths relatively smoothly. Otherwise, robust socket
code tends to need while loops and tedious arithmetic.

HTH

On Mon, Aug 8, 2022 at 10:59 AM Andreas Croci <andrea.croci@gmx.de> wrote:

> I would like to write a program, that reads from the network a fixed
> amount of bytes and appends them to a list. This should happen once a
> second.
>

RE: Parallel(?) programming with python

<mailman.241.1660064768.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19177&group=comp.lang.python#19177

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Joseph.S...@Teledyne.com (Schachner, Joseph (US))
Newsgroups: comp.lang.python
Subject: RE: Parallel(?) programming with python
Date: Tue, 9 Aug 2022 17:04:51 +0000
Lines: 44
Message-ID: <mailman.241.1660064768.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
X-Trace: news.uni-berlin.de 9aK7GsdSqxEVhxVD/21L0AhY/TjyY+X8WVrMv0Subf4Q==
Return-Path: <prvs=2136ec3fa=Joseph.Schachner@teledyne.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.010
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '2022': 0.05; 'joseph':
0.05; 'network.': 0.05; 'parallel': 0.05; 'thread': 0.05;
'subject:python': 0.06; 'below)': 0.07; 'filled': 0.09; 'numpy':
0.09; 'received:namprd14.prod.outlook.com': 0.09; 'scipy': 0.09;
'append': 0.16; 'appended': 0.16; 'computations': 0.16; 'far,':
0.16; 'initialize': 0.16; 'items,': 0.16; 'scipy,': 0.16;
'slicing': 0.16; 'structures,': 0.16; 'subject:programming': 0.16;
'python': 0.16; 'to:addr:python-list': 0.20; 'basically': 0.22;
'goal': 0.23; 'list,': 0.24; 'to:name:python-list@python.org':
0.24; 'skip:- 10': 0.25; 'stuff': 0.25; 'programming': 0.25;
'sensitive': 0.26; 'else': 0.27; 'coming': 0.27; 'function': 0.27;
'done': 0.28; 'thinking': 0.28; 'whole': 0.30; 'approach': 0.31;
'comment': 0.31; 'program,': 0.31; 'saved': 0.31; 'program': 0.31;
'question': 0.32; "i'm": 0.33; 'same': 0.34; 'header:In-Reply-
To:1': 0.34; 'count': 0.36; "it's": 0.37; 'this.': 0.37; 'way':
0.38; 'could': 0.38; 'read': 0.38; 'single': 0.39; 'list': 0.39;
'use': 0.39; 'received:unknown': 0.39; '(see': 0.40; 'happen':
0.40; 'program.': 0.40; 'something': 0.40; 'should': 0.40; 'best':
0.61; 'from:': 0.62; 'to:': 0.62; 'come': 0.62; 'data,': 0.63;
'hours': 0.63; 'once': 0.63; 'down': 0.64; 'your': 0.64; 'parts':
0.65; 'six': 0.65; 'look': 0.65; 'less': 0.65; 'time.': 0.66;
'time,': 0.67; 'further': 0.69; 'depending': 0.70; 'front': 0.70;
'easy': 0.74;
'received:nam10-bn7-obe.outbound.protection.outlook.com': 0.76;
'business': 0.77; 'sent:': 0.78; 'locking': 0.84; 'want.': 0.84
IronPort-Data: A9a23:SK7GWaJw65d/iVmwFE+RmpQlxSXFcZb7ZxGr2PjKsXjdYENS1mEAn
TEfW2qGaa6LYWSke953bdyz/RhVuJ/WmNFlGgJorCE8RH909fbIVI+TRqvSF3rKdJGbFBo/h
yk9QoCYdpxsFieEzvuJGuK8xZWp/fjQHtIQMMadZmYrA1cMpB4J0XpLg/Q+jpNjne+3CgaMv
cKai8DEMTdJ4RYtWo4pw/nrRC1H7a2aVAww7gRWicBj5Df2i3QTBZQDEqC9R1OQrl58R7PSq
07rldlVz0uBl/sfIorNfoXTKyXmdoXv0T2m1hK6bUQAbi9q/UTe2o5jXBYVhNw+Zz+hx7idw
/0U3XC8pJtA0gQhV43xXjEBexySM5Gq95f1cVbgkeWi9nf6LWDQ+9xBUHw8HJchr7Mf7WFmr
ZT0KRgwVUrGudqT+53+b8Nc3p1lMMX6ep8Svnxs3DfUS/0hRPgvQY2TvocegW923JwTW62GD
yYaQWMHgBDoQRpUN08XTqk1nO6jhn/yaRVEpVaYqbsx7i7YywkZPL3FboeJIo3SFJk9ckCwl
1/P4VzzKEAjP9GO8jCVzVCj3L7vknauMG4VPPjinhJwu3WawGAJBRRQXkG8qviRhUuuHd5SQ
2QM6zYuqq538E2wUvHlTgG4p3jCuQQTM+e8CMVjs1nLl/KSuVrEQDNcJtJcVOEbWAYNbWRC/
je0cxnBX1SDbJX9paqhy4qp
IronPort-HdrOrdr: A9a23:AtrE26zchfOOoAwf4TmSKrPxqOskLtp133Aq2lEZdPULSKOlfp
GV8MjziyWYtN9IYgBapTnyAtj7fZq6z+8+3WBxB8boYOCIghrOEGgP1+vfKnjbalXDH41mpO
pdmspFebvN5DFB5K6QimfYLz9j+qj/zEnBv5aY854Hd3AJV0gU1XYcNu/tKDwSeOApP+tbKL
Osou584xawc3Ueacq2QlMfWfLYmtHNnJX6JTYbGh8O8mC1/H+VwY+/NyLd8gYVUjtJz7tn23
PCiRbF6qKqtOz+4gPA1lXU849dlLLau5R+7Y23+4YowwfX+0aVjbdaKv6/VfcO0aOSAWMR4Z
jxStEbToFOAj3qDyWISFDWqnTdOX4VmgPfIBmj8D3eSIXCNUwH48Ytv/MnTjLJr0Unp91yy6
RNwiaQsIdWFwrJmGDn68HPTAwCrDvDnZMOq59ms5Vka/poVJZB6YgEuE9FGpYJGyz3rIghDe
l1FcnZoPJba0mTYXzVtnRmhIXEZAV6Ij6WBkwZ/sCF2Tlfm350i0Me2cwEh38FsJYwUYNN6e
jIOrlh0LtOUsgVZ6RgA/ppe7r/NkXdBRbXdG6CK1XuE68Kf3rLtp7s+b0woPqnfZQZpaFC7a
gpkGkox1LaV3ieefFmhqc7gywlaF/NLgjQ9g==
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=B/JgToKz430bgmODosW6K/1Zl4m4nt2n9nX059vgtRo0XDdURk39hbdwWf7C6wm3tZTj9xiYj7ponKZDd2bVS2PS5ame5LSLjptDxrwY+yhPt1rxJb7LjNZXMLgpLvo6v4+bBudH3n7nyTkFMayndbk6Ipgp70RrXbyh0ov3dDLToyxinZzO1/jgnbc6EyG93ouTN0XJJ0/A389Xew2H0+XIkIbjIe1WoxjSkkKKcOhjEZaca+x6L7GC6SIPCM97k6ZFEXISAf18XPxL1Wpaoa/zHxQOZobJhvhZFSl/E7QpMFX1+1fAZSgTj26/JgmC1bejE88t0zsz8IBZSeELMQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=D6464iZIhuDdVl2Czhd21K2Qqq4aXWnhQGCqhXIXZYI=;
b=RdxdBON0YXZoEkzUotruTaG+Ilob2Bg9k8G2gRP9AAFnVnzhQBQjh7X3XjTtlnL7vENmoWV6XQ4oE9xvY/sAh7jFoTOmCB6Va/azzN1yPSVKiW5nhjxDeZrxZDq5fPU/bDxiRCbW8031jh94NnZuJjinbFyA/a/jeVfcnYx0DQNB4qz2vByaR2b2jFJgiI0vCtoC6TpG1SJBG7CgvTrTABWVAGAMK0hjVpP4A69iKhCmhPQmbMbVetqyXBaN8jsFlMi9zFvaIa+jlgNKPXylJZ2CVaB5fgYKy+6/oN/s46v9gNniI3pYb1i/Nf8031fbmM2oW0KqDGOMvGvix9OX5Q==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=teledyne.com; dmarc=pass action=none header.from=teledyne.com;
dkim=pass header.d=teledyne.com; arc=none
Thread-Topic: Parallel(?) programming with python
Thread-Index: AQHYrAnqlIxSBOr9CEy4GDPbbtpWVa2mx9rw
In-Reply-To: <tcqpju$1u59$1@gioia.aioe.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels: MSIP_Label_0d178f3f-9d62-4d87-b8af-200399509a39_Enabled=true;
MSIP_Label_0d178f3f-9d62-4d87-b8af-200399509a39_SetDate=2022-08-09T17:04:50Z;
MSIP_Label_0d178f3f-9d62-4d87-b8af-200399509a39_Method=Standard;
MSIP_Label_0d178f3f-9d62-4d87-b8af-200399509a39_Name=Company Sensitive;
MSIP_Label_0d178f3f-9d62-4d87-b8af-200399509a39_SiteId=e324592a-2653-45c7-9bfc-597c36917127;
MSIP_Label_0d178f3f-9d62-4d87-b8af-200399509a39_ActionId=39b91e8d-da9d-46e4-bdf1-2cc45554a6ee;
MSIP_Label_0d178f3f-9d62-4d87-b8af-200399509a39_ContentBits=2
authentication-results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=Teledyne.com;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 18253565-db3c-49bc-f13b-08da7a294686
x-ms-traffictypediagnostic: CH2PR14MB3914:EE_
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: 424RaI83DemeicvqwPI+jAwA2twC8OJzyWAgEND5JkH9jBZTegxPKfX8JUSJHFNX7N3gC7mx2u3W76X6RPGzXU/S7JzJVvgJIZ+BxflZBcKKX25bH+GxTG0r5HY66vDoXqzBzupRXigDmc7ik6iQyEgit3MVJrpORjbdAAAthgypqvD+kW9iKOD105igmRNCKmYJqFj22SfQUusOA9cfSGbd4dQJjZahrxUBEm5jJWvEOZ2bQB/8lZbyBIfATM3p4JmU5jLRsCqQ1cBVcpWaw5qLe3/Z0NtqgiYEdKvZXgS7Imj4GPK3vtdi70s672fhebTkJA7mMwLgV1zFzp/ympRQsXz5Mu9HPQR2rvZEjw68ISVOFTuOwDw7pKE5+aym8QWxgdLPcczrW0Yo/ENV63RkVfzogINRRfpOa7RN+mP3Nn87uR66zhM2D7vEV9KXc5Y+xP9D833FYBjTmqvuQtiiH7gLiC1CLw3Z8+1WUPxKdVNpgv5sE9kEHWNQpf8TprZNNHFBeCJGE/ZgdQEpcjbSDPayM4UeQdlPv/3jP9DyEmjiQrGE/OWDB34pgLl6QFpbyL/wFZmmGUVjCSJnf91BHPnQCg36ER0t0lVHuFdQQod0NiKB7PHZyzZhWgcJEbkd57coZqFSRhH3NfIRfJaTmK764xntqMSJ06RIl20vji0t+q9GCl0UhyvLwMrQHQ1W/1TN2VUe3d0OOO5BQzmePTtQk91t6RqyPJ/XGqRiLOFa9BP4xtJAVKtmJpn3u4p7EvDWd3NWoG5QJ3pOCN5U6YZd3T7wQHayMQS3HWgqqN3FbbVPMAHL2uz1Bff4
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:BN8PR14MB2851.namprd14.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230016)(346002)(39860400002)(396003)(376002)(136003)(366004)(53546011)(6506007)(7696005)(2906002)(41300700001)(83380400001)(38100700002)(26005)(122000001)(33656002)(38070700005)(186003)(9686003)(76116006)(8676002)(66946007)(71200400001)(66446008)(64756008)(66476007)(110136005)(66556008)(316002)(86362001)(8936002)(52536014)(478600001)(55016003)(5660300002);
DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: DHr4MMOppD/fY5mJSArqoURJYDkXhw43hb3n0AzGbc8lE
MhmONFaLPNbfnl6ETYDLSxcadzczSeJit6rhyGY/DSNYr
LWVO/7X176s+pgdqxJNPZRQveIgGQqwYThERWYW3kcGZM
KAvHsckikgKLVPpBtMQJ+HpH4NvrECGx67CArLVG0Ycxj
OAnR21T/c68nFCD+NLZTcFzoPNh1XG4q0vDxwQAQWKffJ
DwZ41l5tQrjF5/emT0t2BoZBCxiO6lpiiZ2hNdGZjP743
KPIt4vyuSW+EP/SVqaPFPmC9F4skWvYiTcQ5oJnrDRg7Q
34fFv/s/vv//pZSEQuJRNuHxLBMWtEpHon45meTxc4rXW
p2urVuQUoSpyKi2XC49YzAAsPgKWg7Nzpha/veXAZ+g07
DlGbXRYjxiPzr92+5hDl9W7KnPxX5ANqTLdOAyEQNg9os
0lTSoJSKaWi6H/YYdOQ6uKqQkYcf0o753MK8VgA9IvgSZ
hfxbZYqKUyG+aTKD0vE6PEb2FDMF5cwJNo3lvQgS8ZFgF
9wU/23Z6lyBCdFmvvWoDpW1EHWZ1t4XITZdyQ7jojVe3t
wJ6I0YJDu8OhWL9XLXVXMiSTukfZhOvoV0mYaYCl2whvH
YSV24V/YEnHw3hoJOIjvAnbGcMAgUQDc8KiNStq/rwa5a
Vriw+bQrc5ocV75wT7IwE1ar0+5xwNwK4apOJQmKBnpGA
6x6dnIlOVeU/VbLfG16ZmFMsJDuoGPzkSc/6ltJjETbKB
AxMhuhavg6/FH/NKasUQl3J6q9ljHElZbl1VVKvho3IXD
55eEGJAKa+jLigYSgA+0px+hUHuTE9zZRKuuFNAqLANA4
dN3x/B48dwJ2+FpqJEnXn+iCChZVehLYRzlfouGCR0JfD
EDUkCG/5kw3uJ9SGQW3TH3oX42J1gJrykgW0UJ4Jx9bcj
5dA4K4CQ3lluipCmlD2SVJ0XIr077M2LsbwmLrvUmJwRY
XgejTFAIaHyWrF6liTdDQac0tPP48L1t+JgMpiXVpxK5y
ebRqqKOooCrAmFelTkRGgdFIeSrEnrc+U39SArVaMjGj5
uRpCE9WLoBk3lWaDfeFrSoezFJyQ/8MKbw5WuQw2SXEEe
gJitMQ1h8lo8UVQ05DHVBnshA0VqzR2bbPjGGxzbeCknL
+1ytZ2se5Whm/KrUEYK5/jq8FC3uJNEFcWSakiA1iAlEt
mySypsw/VDEbXtR6jvIzdzfiIRenz234urQ1FzBnE0Dco
htuiCyMZ3ifFF0jelFNiWvsrSjeUEMSNtX0orlrezC4ty
Z3uVwWgMfArWNQfOZFv1ro+U/UX8ZZLhAz2JPY5iDuis5
fX4h2VlwDKk0oVg28O3VwU+q+Xufl2cOIqpYNP6QJ6xnE
1HMw/0uygwP+MYBF0Qo1sNQL1hj/PVrWDzEyt0aftdM6b
a4UVnPpUMfovMQNaqGxohDUmtNcAKuECXFHMj2EkYApRI
dQ6Zvgp40CWGMmq5dUBJnUhcpP/ikWhNt+r/RhInMaB6b
Ewd2b9z2IzWe23qMaPNkE0Tn/eLC7EbLr0yZcUzMmgCED
qQtlJ4Oe9GoyDHDhpyh2hzyCjJPwpAgCaT1MIxvGQ61wF
1Q==
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: BN8PR14MB2851.namprd14.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 18253565-db3c-49bc-f13b-08da7a294686
X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Aug 2022 17:04:52.1374 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: e324592a-2653-45c7-9bfc-597c36917127
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: Bs3qgUTGWGh+KKFIsntmMxwv89sA+wXGapklDXx7tkX71zapjXawY7K4uX5FlQddsRPiTlsMnyCIFkGuhgydY63BVLUjeB4l99OVG4AvG1c=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR14MB3914
X-OriginatorOrg: Teledyne.com
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
 by: Schachner, Joseph (U - Tue, 9 Aug 2022 17:04 UTC

Why would this application *require* parallel programming? This could be done in one, single thread program. Call time to get time and save it as start_time. Keep a count of the number of 6 hour intervals, initialize it to 0.
Once a second read data an append to list. At 6 hours after start time, call a function that does an FFT (see comment about scipy below) and increment the count of 6 hour intervals. Call time and save new start time. Continue execution.
After 28 six hour intervals, save the list and then slice the list to shorten it as you want. Reset the count of 6 hour intervals to zero.
The FFT might take a second, even if you use scipy, depending on how long the list is (If you don’t know about numpy and scipy, look them up! You need them. Your list can be an array in numpy).
Saving and slicing the list should take less than a second.
This single thread approach avoids thinking about multiprocessing, locking and unlocking data structures, all that stuff that does not contribute to the goal of the program.
--- Joseph S.

Teledyne Confidential; Commercially Sensitive Business Data
-----Original Message-----
From: Andreas Croci <andrea.croci@gmx.de>
Sent: Monday, August 8, 2022 6:47 AM
To: python-list@python.org
Subject: Parallel(?) programming with python
tI would like to write a program, that reads from the network a fixed amount of bytes and appends them to a list. This should happen once a second.
Another part of the program should take the list, as it has been filled so far, every 6 hours or so, and do some computations on the data (a FFT).
Every so often (say once a week) the list should be saved to a file, shorthened in the front by so many items, and filled further with the data coming fom the network. After the first saving of the whole list, only the new part (the data that have come since the last saving) should be appended to the file. A timestamp is in the data, so it's easy to say what is new and what was already there.
I'm not sure how to do this properly: can I write a part of a program that keeps doing its job (appending data to the list once every second) while another part computes something on the data of the same list, ignoring the new data being written?
Basically the question boils down to wether it is possible to have parts of a program (could be functions) that keep doing their job while other parts do something else on the same data, and what is the best way to do this.

RE: Parallel(?) programming with python

<mailman.246.1660152793.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19183&group=comp.lang.python#19183

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: die...@handshake.de (Dieter Maurer)
Newsgroups: comp.lang.python
Subject: RE: Parallel(?) programming with python
Date: Wed, 10 Aug 2022 19:33:04 +0200
Lines: 4
Message-ID: <mailman.246.1660152793.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
<25331.60368.319662.710495@ixdm.fritz.box>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de SA7X4WxuQBXRJIZvm/ewRQkIISECj5Wmz2e7lXiiSUCg==
Return-Path: <dieter@handshake.de>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'joseph': 0.05; 'library.':
0.05; 'parallel': 0.05; "python's": 0.05; 'thread': 0.05;
'subject:python': 0.06; 'cc:addr:python-list': 0.09; '(us)': 0.16;
'initialize': 0.16; 'subject:programming': 0.16;
'cc:addr:python.org': 0.20; 'cc:2**1': 0.23; 'received:de': 0.23;
'done': 0.28; 'module': 0.31; 'header:In-Reply-To:1': 0.34;
'count': 0.36; 'could': 0.38; 'single': 0.39; 'use': 0.39;
'wrote': 0.39; 'program.': 0.40; 'header:Received:6': 0.67;
'received:88': 0.84
In-Reply-To: <BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid
(x86_64-linux-gnu)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <25331.60368.319662.710495@ixdm.fritz.box>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
 by: Dieter Maurer - Wed, 10 Aug 2022 17:33 UTC

Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000:
>Why would this application *require* parallel programming? This could be done in one, single thread program. Call time to get time and save it as start_time. Keep a count of the number of 6 hour intervals, initialize it to 0.

You could also use the `sched` module from Python's library.

Re: Parallel(?) programming with python

<q8t7fht4vdvnhea5e0p7npv5a7si5tklrn@4ax.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19184&group=comp.lang.python#19184

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 10 Aug 2022 18:19:01 +0000
From: wlfr...@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Wed, 10 Aug 2022 14:19:37 -0400
Organization: IISS Elusive Unicorn
Message-ID: <q8t7fht4vdvnhea5e0p7npv5a7si5tklrn@4ax.com>
References: <tcqpju$1u59$1@gioia.aioe.org> <BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com> <25331.60368.319662.710495@ixdm.fritz.box> <mailman.246.1660152793.20444.python-list@python.org>
User-Agent: ForteAgent/8.00.32.1272
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 20
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-kiCqk6kkocbXutf0gvmRb69OSGVxWKpoz1DFlDvOOoILmz4oJToiq7qXaYU3TCruOiYgHZeRwa7yPw4!0uTYsBMfqzThwZ+MQ/oMUSDfR4x8KycnOC4Gsd2RnZQy5cBUqaZJIq47yzvt+dzWF8HLOhSA
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Dennis Lee Bieber - Wed, 10 Aug 2022 18:19 UTC

On Wed, 10 Aug 2022 19:33:04 +0200, "Dieter Maurer" <dieter@handshake.de>
declaimed the following:

>Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000:
>>Why would this application *require* parallel programming? This could be done in one, single thread program. Call time to get time and save it as start_time. Keep a count of the number of 6 hour intervals, initialize it to 0.
>
>You could also use the `sched` module from Python's library.

<sigh> Time to really read the library reference manual again...

Though if I read this correctly, a long running action /will/ delay
others -- which could mean the (FFT) process could block collecting new
1-second readings while it is active. It also is "one-shot" on the
scheduled actions, meaning those actions still have to reschedule
themselves for the next time period.

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Re: Parallel(?) programming with python

<mailman.247.1660157058.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19185&group=comp.lang.python#19185

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: 2QdxY4Rz...@potatochowder.com
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Wed, 10 Aug 2022 13:43:47 -0500
Lines: 29
Message-ID: <mailman.247.1660157058.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
<YvP8Y70sLHedQns/@anomaly>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de weHyJcEJ+zPALaWRI97ZlwF5jYZJM/6XKqU503MrY9cw==
Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'joseph': 0.05; 'parallel':
0.05; 'thread': 0.05; 'subject:python': 0.06; 'happens.': 0.09;
'received:78': 0.09; 'simplicity': 0.09;
'from:addr:2qdxy4rzwzuuilue': 0.16; 'from:addr:potatochowder.com':
0.16; 'handful': 0.16; 'initialize': 0.16; 'os,': 0.16;
'practice,': 0.16; 'received:136.243': 0.16; 'received:172.58':
0.16; 'received:78.46': 0.16; 'received:78.46.172': 0.16;
'received:78.46.172.2': 0.16; 'received:sslproxy05.your-
server.de': 0.16; 'received:www458.your-server.de': 0.16;
'received:your-server.de': 0.16; 'recover': 0.16;
'subject:programming': 0.16; 'wrote:': 0.16; 'python': 0.16;
'to:addr:python-list': 0.20; 'received:de': 0.23; 'done': 0.28;
'board': 0.28; 'computer': 0.29; 'it,': 0.29; 'program': 0.31;
'cool': 0.32; 'received:136': 0.32; 'said,': 0.32; 'develop':
0.32; 'header:In-Reply-To:1': 0.34; 'pending': 0.35; "we're":
0.35; 'addressed': 0.36; 'count': 0.36; 'year': 0.36; "it's":
0.37; 'could': 0.38; 'single': 0.39; 'program.': 0.40; 'seconds':
0.40; "there's": 0.61; 'here': 0.62; 'once': 0.63; 'our': 0.64;
'definition': 0.64; 'your': 0.64; 'per': 0.68;
'charset:iso-8859-1': 0.73; 'telephone': 0.74; 'highly': 0.78;
'go,': 0.84; 'happen,': 0.84; 'leap': 0.84; 'convenience': 0.91;
'physically': 0.91
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com
X-Virus-Scanned: Clear (ClamAV 0.103.6/26623/Wed Aug 10 09:55:07 2022)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YvP8Y70sLHedQns/@anomaly>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
 by: 2QdxY4Rz...@potatochowder.com - Wed, 10 Aug 2022 18:43 UTC

On 2022-08-09 at 17:04:51 +0000,
"Schachner, Joseph (US)" <Joseph.Schachner@Teledyne.com> wrote:

> Why would this application *require* parallel programming? This could
> be done in one, single thread program. Call time to get time and save
> it as start_time. Keep a count of the number of 6 hour intervals,
> initialize it to 0.

In theory, you are correct.

In practice, [stuff] happens. What if your program crashes? Or the
computer crashes? Or there's a Python update? Or an OS update? Where
does all that pending data go, and how will you recover it after you've
addressed whatever happened? ¹

OTOH, once you start writing the pending data to a file, then it's an
extremely simple leap to multiple programs (rather than multiple
threads) for all kinds of good reasons.

¹ FWIW, I used to develop highly available systems, such as telephone
switches, which allow [stuff] to happen, and yet continue to function.
It's pretty cool to yank a board (yes, physically remove it, without
warning) from the system without [apparently] disrupting anything. Such
systems also allow for hardware, OS, and application upgrades, too
(IIRC, we were allowed a handful of seconds of downtime per year to meet
our availability requirements). That said, designing and building such
a system for the sakes of simplicity and convenience of the application
we're talking about here would make a pretty good definition of
"overkill."

RE: Parallel(?) programming with python

<mailman.248.1660157679.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19186&group=comp.lang.python#19186

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: Parallel(?) programming with python
Date: Wed, 10 Aug 2022 14:54:36 -0400
Lines: 61
Message-ID: <mailman.248.1660157679.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
<25331.60368.319662.710495@ixdm.fritz.box>
<011901d8acea$a32bc8b0$e9835a10$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de 7FYNeq+81+s0lTABrLaoWQ+cys/k8TT69IbRyqoMhSRw==
Return-Path: <avi.e.gross@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=lm7Z4a2H;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.010
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '2022': 0.05; 'fairly':
0.05; 'joseph': 0.05; 'library.': 0.05; 'parallel': 0.05;
"python's": 0.05; 'thread': 0.05; 'subject:python': 0.06;
'python.': 0.08; 'cc:addr:python-list': 0.09; 'collecting': 0.09;
'memory.': 0.09; 'parties': 0.09; 'received:209.85.219': 0.09;
'tasks,': 0.09; 'cc:no real name:2**0': 0.14; 'url:mailman': 0.15;
'memory': 0.15; '(us)': 0.16; 'aside': 0.16; 'dieter': 0.16;
'generalized': 0.16; 'idea.': 0.16; 'initialize': 0.16; 'level,':
0.16; 'locks': 0.16; 'opinion,': 0.16; 'queues': 0.16; 'run,':
0.16; 'somewhat': 0.16; 'structures': 0.16; 'subject:programming':
0.16; 'ways.': 0.16; 'python': 0.16; 'applications': 0.17;
'message-id:@gmail.com': 0.18; 'cc:addr:python.org': 0.20;
'machine': 0.22; 'written': 0.22; 'lines': 0.23; 'run': 0.23;
'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'cc:2**0': 0.25;
'programming': 0.25; 'url-ip:188.166/16': 0.25; 'seems': 0.26;
'task': 0.26; 'wednesday,': 0.26; 'old': 0.27; 'done': 0.28;
'example,': 0.28; 'asked': 0.29; 'it,': 0.29; 'module': 0.31;
'url-ip:188/8': 0.31; 'think': 0.32; 'question': 0.32; 'answers':
0.32; 'discussions': 0.32; 'python-list': 0.32; 'structure': 0.32;
'but': 0.32; 'there': 0.33; 'hold': 0.33; 'able': 0.34; 'same':
0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'running': 0.34; 'one.': 0.35; 'yes,': 0.35;
'from:addr:gmail.com': 0.35; 'also,': 0.36; 'files': 0.36;
'count': 0.36; 'processes': 0.36; 'people': 0.36; 'those': 0.36;
'necessarily': 0.37; 'main': 0.37; 'really': 0.37; 'using': 0.37;
'received:209.85': 0.37; 'way': 0.38; 'could': 0.38;
'received:209': 0.39; 'two': 0.39; 'single': 0.39; 'use': 0.39;
'block': 0.39; 'on.': 0.39; 'received:100': 0.39; 'shared': 0.39;
'wrote': 0.39; 'still': 0.40; 'data.': 0.40; 'processed': 0.40;
'program.': 0.40; 'situation': 0.40; 'something': 0.40; 'want':
0.40; 'to:none': 0.60; 'best': 0.61; '10,': 0.61; 'from:': 0.62;
'to:': 0.62; 'here': 0.62; 'come': 0.62; 'days': 0.62; 'hours':
0.63; 'send': 0.63; 'between': 0.63; 'share': 0.63; 'down': 0.64;
'full': 0.64; 'lock': 0.64; 're:': 0.64; 'requirement': 0.64;
'your': 0.64; 'parts': 0.65; 'less': 0.65; 'let': 0.66;
'receiving': 0.66; 'acted': 0.69; 'and,': 0.69; 'cc:': 0.69;
'collect': 0.69; 'obvious': 0.69; 'safer': 0.69; 'sources,': 0.69;
'stores': 0.69; 'within': 0.69; 'solutions': 0.70; 'schedule':
0.73; 'poor': 0.76; 'sent:': 0.78; 'database': 0.80; 'moment':
0.81; 'choices': 0.84; 'horrible': 0.84; 'pause': 0.84; 'largely':
0.91; 'receives': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:cc:from
:from:to:cc; bh=5BsnT17l9HSkJjMJVXaW70TDtE9PdxSeMT6UwvTx7pM=;
b=lm7Z4a2HRk1AhxsUZa8i0lULAUFMG5RGvJrbgGbu/UGf5pqWB64c1GTYCnlumO6ZxF
j7Y+pMji70rgfaKS77G9TkY9jObS/6AcxcI1PYsWAM7PWohwAM7Y0rrkQwtu4UevJxt7
667Cnw+3sI9wcwO61ArkoNBeEhuklBpAirIV8USW95PP+Yok9+F+TZqeiMSiQHCRGevI
9Ng+RLPVDaVxGtjnUWIWMyZRtfLFCk4yjDn0bx/c7oMKV1WxRsp5GN0qcX3lJK/ABuw8
c7SvBEi1o7w1mNiUSFBXgC3kBneJij4uJILubxMm2eOqOdgDiQyob66qb7Zvl4YaZk8a
EPtg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:cc:from
:x-gm-message-state:from:to:cc;
bh=5BsnT17l9HSkJjMJVXaW70TDtE9PdxSeMT6UwvTx7pM=;
b=UDF+82uIaciHJqtU/0oSkr1Oj3MEL6wEN9/SJT9lTfJoCdDGalOiHEyHU2vWDaxdDE
SpHo/mjwbFdoa4bSsOWjoslEPnESiD8I5Q5CwB57f9fSbbpON6+PsWRmcAEgSA4PknZZ
8tRQ5Jpar80C+2/HSHj6o/49bGZpaRAgMwWrm0EhAjek4XNm2IdNYzl/3p8VaHnnD56+
0b1UMcsRDCnrXaaZtgejaaLt3qQ1TqsfTG+h7ydJchOBswTeP56/kOjikB5CAHBcD5V+
dV4wGCod2mVXKJRYaLmkaSpC5y2G5tUvuv2OurQKZ3G/wYjfUyHsQZKultgbIeGTmmK9
8BHg==
X-Gm-Message-State: ACgBeo25J3Bkqz6Q26t8FMRE+YSaaCi7FMJJeMlZOlH4hjUWOXV79k5q
pW0Kp9jThYYt0bg+zionkGUyvn9APw+VWw==
X-Google-Smtp-Source: AA6agR73bkDFcmJyq8UVMRvECxibWXGepcJQILuNCaFeGWgChkDZX3BU85Nll+T8kgiU4MI2c27xzg==
X-Received: by 2002:a05:6214:d66:b0:476:a5d7:57e5 with SMTP id
6-20020a0562140d6600b00476a5d757e5mr25486162qvs.113.1660157677625;
Wed, 10 Aug 2022 11:54:37 -0700 (PDT)
In-Reply-To: <25331.60368.319662.710495@ixdm.fritz.box>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQGIaoHVJxGa2SnrkgPY2vGzOeJjGwGwfdiaAo/nGnWuJvcYsA==
Content-Language: en-us
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <011901d8acea$a32bc8b0$e9835a10$@gmail.com>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
<25331.60368.319662.710495@ixdm.fritz.box>
 by: - Wed, 10 Aug 2022 18:54 UTC

There are many possible discussions we can have here and some are not really
about whether and how to use Python.

The user asked how to do what is a fairly standard task for some people and
arguably is not necessarily best done using a single application running
things in parallel.

So, yes, if you have full access to your machine and can schedule tasks,
then some obvious answers come to mind where one process listens and
receives data and stores it, and another process periodically wakes up and
grabs recent data and processes it and perhaps still another process comes
up even less often and does some re-arrangement of old data.

And, yes, for such large volumes of data it may be a poor design to hold all
the data in memory for many hours or even days and various ways of using a
database or files/folders with a naming structure are a good idea.

But the original question remains, in my opinion, a not horrible one. All
kinds of applications can be written with sets of tasks run largely in
parallel with some form of communication between tasks using shared data
structures like queues and perhaps locks and with a requirement that any
tasks that take nontrivial time need a way to buffer any communications to
not block others.

Also, for people who want to start ONE process and let it run, and perhaps
may not be able to easily schedule other processes on a system level, it can
be advantageous to know how to set up something along those lines within a
single python session.

Of course, for efficiency reasons, any I/O to files slows things down but
what is described here as the situation seems to be somewhat easier and
safer to do in so many other ways. I think a main point is that there are
good ways to avoid the data from being acted on by two parties that share
memory. One is NOT to share memory for this purpose. Another might be to
have the 6-hour process use a lock to move the data aside or send a message
to the receiving process to pause a moment and set the data aside and begin
collecting anew while the old is processed and so on.

There are many such choices and the parts need not be in the same process or
all written in python. But some solutions can be generalized easier than
others. For example, can there become a need to collect data from multiple
sources, perhaps using multiple listeners?

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Dieter Maurer
Sent: Wednesday, August 10, 2022 1:33 PM
To: Schachner, Joseph (US) <Joseph.Schachner@Teledyne.com>
Cc: Andreas Croci <andrea.croci@gmx.de>; python-list@python.org
Subject: RE: Parallel(?) programming with python

Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000:
>Why would this application *require* parallel programming? This could be
done in one, single thread program. Call time to get time and save it as
start_time. Keep a count of the number of 6 hour intervals, initialize it
to 0.

You could also use the `sched` module from Python's library.
--
https://mail.python.org/mailman/listinfo/python-list

Re: Parallel(?) programming with python

<mailman.249.1660163387.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19187&group=comp.lang.python#19187

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: hjp-pyt...@hjp.at (Peter J. Holzer)
Newsgroups: comp.lang.python
Subject: Re: Parallel(?) programming with python
Date: Wed, 10 Aug 2022 22:29:38 +0200
Lines: 54
Message-ID: <mailman.249.1660163387.20444.python-list@python.org>
References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
<25331.60368.319662.710495@ixdm.fritz.box>
<mailman.246.1660152793.20444.python-list@python.org>
<q8t7fht4vdvnhea5e0p7npv5a7si5tklrn@4ax.com>
<20220810202938.rakcvusfgenmvsrx@hjp.at>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="xxny2fouxtqazygw"
X-Trace: news.uni-berlin.de 3QYkX0otRMzrBO3b/9CH6QMy0XqMfHgtuQOb3yZpKdsQ==
Return-Path: <hjp-python@hjp.at>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2022': 0.05; 'content-
type:multipart/signed': 0.05; 'joseph': 0.05; 'parallel': 0.05;
'thread': 0.05; 'subject:python': 0.06; 'aug': 0.07; 'collecting':
0.09; 'content-type:application/pgp-signature': 0.09; 'delay':
0.09; 'filename:fname piece:asc': 0.09; 'filename:fname
piece:signature': 0.09; 'filename:fname:signature.asc': 0.09;
'"creative': 0.16; '(us)': 0.16; '+0200,': 0.16; '__/': 0.16;
'active.': 0.16; 'challenge!"': 0.16; 'from:addr:hjp-python':
0.16; 'from:addr:hjp.at': 0.16; 'from:name:peter j. holzer': 0.16;
'hjp@hjp.at': 0.16; 'holzer': 0.16; 'initialize': 0.16; 'matter?':
0.16; 'reality.': 0.16; 'stross,': 0.16; 'subject:programming':
0.16; 'url-ip:212.17.106.137/32': 0.16; 'url-ip:212.17.106/24':
0.16; 'url-ip:212.17/16': 0.16; 'url:hjp': 0.16; '|_|_)': 0.16;
'wrote:': 0.16; 'to:addr:python-list': 0.20; 'maybe': 0.22;
'depends': 0.25; 'bit': 0.27; 'done': 0.28; 'sense': 0.28;
'(this': 0.32; 'but': 0.32; 'mean': 0.34; 'header:In-Reply-To:1':
0.34; 'running': 0.34; 'count': 0.36; 'others': 0.37; 'though':
0.37; 'could': 0.38; 'read': 0.38; 'quite': 0.39; 'single': 0.39;
'block': 0.39; 'wed,': 0.39; 'wrote': 0.39; 'program.': 0.40;
'connection': 0.61; 'received:212': 0.62; 'involve': 0.64;
'received:userid': 0.66; 'consumer': 0.67; 'following:': 0.69;
'url-ip:212/8': 0.69; 'received:at': 0.84; 'blocked': 0.93;
'notice.': 0.93
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <q8t7fht4vdvnhea5e0p7npv5a7si5tklrn@4ax.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <20220810202938.rakcvusfgenmvsrx@hjp.at>
X-Mailman-Original-References: <tcqpju$1u59$1@gioia.aioe.org>
<BN8PR14MB28516BC06563B40BFA93AC6BF5629@BN8PR14MB2851.namprd14.prod.outlook.com>
<25331.60368.319662.710495@ixdm.fritz.box>
<mailman.246.1660152793.20444.python-list@python.org>
<q8t7fht4vdvnhea5e0p7npv5a7si5tklrn@4ax.com>
 by: Peter J. Holzer - Wed, 10 Aug 2022 20:29 UTC
Attachments: signature.asc (application/pgp-signature)

On 2022-08-10 14:19:37 -0400, Dennis Lee Bieber wrote:
> On Wed, 10 Aug 2022 19:33:04 +0200, "Dieter Maurer" <dieter@handshake.de>
> declaimed the following:
> >Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000:
> >>Why would this application *require* parallel programming? This
> >>could be done in one, single thread program. Call time to get time
> >>and save it as start_time. Keep a count of the number of 6 hour
> >>intervals, initialize it to 0.
[...]
> Though if I read this correctly, a long running action /will/
> delay others -- which could mean the (FFT) process could block
> collecting new 1-second readings while it is active.

Certainly, but does it matter? Data is received from some network
connection and network connections often involve quite a bit of
buffering. If the consumer is blocked for 3 or 4 or maybe even 20
seconds, the producer might not even notice. (This of course depends
very much on the details which we know nothing about.)

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

Attachments: signature.asc (application/pgp-signature)
Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor