Re: Long running nautilus extensions



В Чтв, 16/06/2005 в 20:08 +0000, Lorenzo E. Danielsson пишет:
> 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?
> 
> Lorenzo
> 
Right, you are just make process sleep instead of processing events.

There are number of ways to do it. The closest to your current
implementation is usage
of gobject.timeout_add but probably it also may have sense to emit
signals in your threads
when they finish tasks and in main thread just connect to signal. 

www.pygtk.org has a number of tutorials that may help you with this kind
of question.




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