[Pyobjc-dev] FTP Lib with a Cocoa application
Brought to you by:
ronaldoussoren
From: Rob <rob...@gm...> - 2009-09-08 00:49:38
|
My apologies if this has already been discussed / answered, but I couldn't figure out how to search the archives. I am writing a Cocoa based FTP uploading application using ftplib and threading and I've hit a bit of a snag. I am sure it is something I am doing wrong, but I wanted to check to see if I am way off. What appears to be happening is when I run the application within the Cocoa GUI the FTP uploading part hangs when it tries to do the upload (staring it's own thread I am assuming). I am guessing it's a "thread in a thread" issue? (total guess obviously) When I run the threaded library directly from __main__ on the command line, with FTP set to debug I get the following: *cmd* 'TYPE I' *put* 'TYPE I\r\n' *get* '200 Type set to I\r\n' *resp* '200 Type set to I' *cmd* 'PASV' *put* 'PASV\r\n' *get* '227 Entering Passive Mode (xxx,xxx,xxx,212,4,3)\r\n' *resp* '227 Entering Passive Mode (xxx,xxx,xxx,212,4,3)' *cmd* 'STOR TestFile.mov' *put* 'STOR TestFile.mov\r\n' *get* '150 Connection accepted\r\n' *resp* '150 Connection accepted' *get* '226 Transfer OK\r\n' *resp* '226 Transfer OK' *cmd* 'QUIT' *put* 'QUIT\r\n' *get* '221 Goodbye\r\n' *resp* '221 Goodbye' Done. However when I run the same code within Cocoa I get the following: **cmd* 'TYPE I'* **put* 'TYPE I\r\n'* **get* '200 Type set to I\r\n'* **resp* '200 Type set to I'* **cmd* 'PASV'* **put* 'PASV\r\n'* **get* '227 Entering Passive Mode (xxx,xxx,xxx,212,4,4)\r\n'* **resp* '227 Entering Passive Mode (xxx,xxx,xxx,212,4,4)'* And it just hangs there. It never gets to the next line. The library that does this is a threaded class: class FTPFile(Thread): that just runs a typical ftp connection and upload in the run method: def run(self): ftp = FTP( self.config.server, self.config.username, self.config.password) etc, etc I can FTP via the command line "ftp" application, and, like I said, when I run the library directly so I don't think it's a server problem. Is there something I may have missed when creating the Cocoa app? Do I have to explicitly allow FTP connections or something (I also have the firewall off)? Or is this a known issue with Cocoa+Python? Thanks for any help, rob -- http://robrohan.com http://twitter.com/robrohan |