Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Friday, 3 March 2017 15:00:00 GMT Ralph Corderoy wrote: > mpg321 has a -l option to loop N times. If N is 0 then forever. So > your callback starts mpg321 with -l and gives it the sorted list of all > the MP3s in the current playlist-directory entry, e.g. > `valkyries/*.mp3'. Then it forgets

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Friday, 3 March 2017 17:46:43 GMT Ralph Corderoy wrote: > Hi Terry, > > > > Change it back to that and take them to be directory names instead, > > > and `daisy/*.mp3' is what you pass to mpg321 using your existing > > > `sorted(...listdir)' functional-programming thingy. Well actually, that

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Ralph Corderoy
Hi Terry, > > But that's not "using your existing... functional-programming > > thingy" mentioned above. > > > > mp3_files = sorted(os.path.join(mp3_subdir, x) for x in > > filter(lambda f: f.lower().endswith(".mp3"), os.listdir(mp3_subdir))) > > No it's not, but that bit of code produces

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Thursday, 2 March 2017 19:36:29 GMT Ralph Corderoy wrote: > GPIO creates *one* thread, not one per add_event_detect(). That one > thread calls the registered callbacks sequentially. You end up with two > threads. > I did keep trying to get across you didn't need more than this. :-) Yes I

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Ralph Corderoy
Hi Terry, > So what was your intention when you wrote those lines: > > r = bell_player.wait(): > if r: > print 'bell_player: mpg321 failed: %#x\n' % r > bell_player = None I was intending that you'd see the results familiar from

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Friday, 3 March 2017 11:31:44 GMT Ralph Corderoy wrote: > Correct. So `if r not in (0, -15):' looks apt. It does to me too. Thanks. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2017-03-07 20:00 Meets, Mailing list, IRC, LinkedIn, ...

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Ralph Corderoy
Hi Terry, > So what happens if the .terminate() doesn't work? Well, it's likely to work in that it will successfully send SIGTERM to mpg321. That's all it's trying to do; the Unix function is called signal(3). (The misleading `terminate' is typical of later Python's cross-platform

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Thursday, 2 March 2017 20:17:53 GMT Ralph Corderoy wrote: > Because this wait() doesn't take any parameters, unlike the threading > module's one. :-) So what happens if the .terminate() doesn't work? Presumably we have to wait for the playback to end, which could be a long time if we are

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Ralph Corderoy
Hi Terry, > > playlists = ('daisy', 'peal', 'vikings', 'march', 'fugue') > > Are these intended to be just names or should they link in some way to > the files to be played. They're the files to be played. > >r = subprocess.call(...mpg321..., 'announce-' + > >

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Friday, 3 March 2017 12:44:30 GMT Ralph Corderoy wrote: > They're the files to be played. Ah. We will have up to six independent playlists, so we would have to manage that too. > Right, so your fchimes_path is always the same file, but it needs to > alter on each cycle for a playlist. Not

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Friday, 3 March 2017 14:03:27 GMT Terry Coles wrote: > On Friday, 3 March 2017 14:00:43 GMT Ralph Corderoy wrote: > > Where do you get your mpg321 program from? A package in the > > distribution? If so, which package, which distribution? Or somewhere > > else? > > On the Pi its the Raspbian

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Friday, 3 March 2017 13:40:07 GMT Terry Coles wrote: > On the principle that I don't need the inner while loop (around > mp3_player.poll() ) as you mentioned in an earlier response, I think that > this would work, but someone would have to go over and start the player > again every 30 mins or

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Ralph Corderoy
Hi Terry, Where do you get your mpg321 program from? A package in the distribution? If so, which package, which distribution? Or somewhere else? Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2017-03-07 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Friday, 3 March 2017 14:00:43 GMT Ralph Corderoy wrote: > Where do you get your mpg321 program from? A package in the > distribution? If so, which package, which distribution? Or somewhere > else? On the Pi its the Raspbian repository and on this machine it's the Kubuntu one. Both appear

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Terry Coles
On Friday, 24 February 2017 15:43:04 GMT Ralph Corderoy wrote: Ralph, Thanks for all your help on the subprocess stuff. I'm sure I have a way forward now. In the meantime, I've been trying to get the MP3 Player to work. From your original suggestions: > playlists = ('daisy', 'peal',

Re: [Dorset] Python Multiprocessing (or Maybe Multithreading)

2017-03-03 Thread Ralph Corderoy
Hi Terry, > > They're the files to be played. > > Ah. We will have up to six independent playlists, so we would have to > manage that too. Oh, that explains why I called the tuple `playlists' originally. :-) Change it back to that and take them to be directory names instead, and `daisy/*.mp3'