Re: Long running nautilus extensions



On Fri, 2005-06-17 at 09:12 +0200, Alexander Larsson wrote:
> On Thu, 2005-06-16 at 20:08 +0000, Lorenzo E. Danielsson wrote:
> > Hi all,
> > 
> > I'm not sure if this is the right place to ask, so if I should be asking
> > this somewhere else could somebody please direct me.
> > 
> > I'm writing an extension using the Python Nautilus extension that
> > converts Mp3 files to Ogg. I create a thread for each file to be
> > converted. While the threads are running I keep the main thread alive
> > by:
> > 
> > while threading.activeCount() > 1:
> > 	time.sleep(3)
> > 
> > The problem is that this causes Nautilus to freeze until the selected
> > files have all been converted. I understand this is because I'm running
> > the extension in the main loop of Nautilus (correct me if I'm wrong). Is
> > there any way to work around this? How do I allow for an extension to
> > run for an extended period of time without blocking Nautilus itself. Is
> > there any call I can make within the loop that will allow Nautilus to do
> > its own processing and then return?
> 
> Nautilus extensions run in the main nautilus thread, and they may
> *never* block. Not even to do simple IO. All IO needs to be
> asynchronous.
> 
> I'm not sure why you need to "keep the main thread alive". I thought the
> idea of using threads for the conversion was to not affect the main
> thread/loop? Is this because the threads need to have the python
> interpreter run on the main thread or something?

Yes, if the main python thread dies, it takes its children with it.

> 
> Maybe a better solution would be to spawn new processes instead of
> threads.

Thanks. You are right. 

> 
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>  Alexander Larsson                                            Red Hat, Inc 
>                    alexl redhat com    alla lysator liu se 
> He's an obese native American matador with a robot buddy named Sparky. She's 
> an enchanted green-skinned femme fatale on her way to prison for a murder she 
> didn't commit. They fight crime! 
> 
> 
> 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]