I'm not sure that applies here... or not sure *how* it applies.

1. My tests have all been with the commandline so there is no
webserver involved.
2. The same methodology works fine elsewhere to spawn secondary
processes (have been using it for a month or so and it works well).
3. I can test and verify that using the multiprocessing module to
spawn a long running (10+ min) background process works fine within
web2py. I get the PID back, store and use it later to kill the
process.
4. Another thread on this list discussed the multiprocessing library:
http://groups.google.com/group/web2py/browse_thread/thread/98e4e0ec731a97a1/cd2520facc0ee6ea?lnk=gst&q=nitesedge#cd2520facc0ee6ea

As far as I can understand (what am I missing?) the only distinction
is opening the pyaudio stream. Perhaps there is an incompatibility
between pyaudio and web2py?

-- Nite


On Jun 1, 12:19 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:
> Yes. The web server will kill requests that take tool long. You must
> run something like this in a background process.
>
> On Jun 1, 10:26 am, Nite <nitese...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I'm trying to start a background process to monitor the audio and am
> > using pyaudio to accomplish it. I started with a separate script, but
> > decided it seemed simpler to move the code into my module.
>
> > The issue is that once I call the p.open to create the stream the
> > subprocess hangs and I never get the pid back. If I remove the "stream
> > =" line then it works fine.
>
> > I started out thinking this was a python issue, but when I test
> > outside of web2py (snip out the appropriate functions and run via cli)
> > it works fine.
>
> > from subprocess import *
> > from multiprocessing import Process, Queue
>
> >         def listener(self, q):
> >             CHANNELS = 2
> >             RATE = 44100
> >             INPUT_BLOCK_TIME = 0.05
> >             FORMAT = pyaudio.paInt16
> >             RATE = 44100
> >             INPUT_FRAMES_PER_BLOCK = int(RATE*INPUT_BLOCK_TIME)
>
> >             p = pyaudio.PyAudio()
> >             stream = p.open(format = FORMAT,
> >                         channels = CHANNELS,
> >                         rate = RATE,
> >                         input = True,
> >                         frames_per_buffer = INPUT_FRAMES_PER_BLOCK)
> >             q.put(os.getpid())
> >             import time
> >             time.sleep(300)
>
> >         def startListener(self):
> >             q = Queue()
> >             p = Process(target=self.listener, args=[q])
> >             p.daemon=True
> >             p.start()
> >             print q.get()
>
> > Is there something about threading or modules that prevents this from
> > working in web2py?
>
> > Any help is appreciated!

Reply via email to