[PyQt] Problem with threaded ftp: Cannot queue arguments of type 'QUrlInfo'

Brian Knudson briank at pipelinefx.com
Wed Nov 21 01:31:49 GMT 2012


On Nov 20, 2012, at 11:44 AM, Brian Knudson wrote:

>> 
>>> Here's some example code (pardon the length).  I would like to be able
>> to
>>> print the listed files/urls from the function "lister".  Ultimately, I'd
>>> like to then have that function formulate new urls & pass them back to
>>> connectAndDownload to download each of the files (of course, this will
>>> require modifications to connectAndDownload, but we're not there yet).
>> 
>> Why use threads at all? QFtp is asynchronous and won't block. If you need
>> to do some blocking processing of the results then create threads for that.
>> 
> 
> Hmm.  Good point.  I've tested this again in the main thread & it works as expected.
> 
> FWIW, I had already written the threaded ftp for multiple ftp streams & was trying to reuse it for this purpose (hence the threads).  Assuming this is a Qt bug, I'll happily skip the threaded bit & move back to the main thread.
> 

I may have spoken too soon.  While this works fine in my example script, when I put it in a QWizardPage, it doesn't run.  I suspect this has something to do with the event loop thinking it has completed (or hasn't started?)

For grins, I created a thread that does nothing but wait.  It waits on the ftp list command to finish, then it finishes.  I then start the thread, then wait on it.  This does not solve the problem, however, as there is still no event loop for the QFtp, so it does nothing.  Clearly, I don't understand how event loops work with QWizardPage and QFtp.

The goal: When a user lands on the given qwizard page, several small text files are downloaded from ftp & the contents of those files are used to drive the rest of the wizard.  I would like for the files to be downloaded as part of initializePage & the UI built around the results.  Is this possible?
Currently, I see the ftp commands being queued up, but none ever run... *unless* there's a problem on the page & I get an exception/traceback (which I suspect does something to the event loop), in which case ftp works as I expect it would - directory listed, filenames printed, etc.  No exception/traceback: no ftp commands completed.  Exception/traceback: all ftp commands complete.

To be concise:  How do you get a QFtp to run commands in a QWizardPage w/o a button click?

Thanks,
-Brian


More information about the PyQt mailing list