Re: [Pyobjc-dev] FTP Lib with a Cocoa application
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2009-09-08 07:26:45
|
On 8 Sep, 2009, at 3:06, Rob wrote: > One more bit of information: > > if I call the threaded bit with: worker.run() instead of worker.start > () the FTP works as I want it, but it hangs the UI while doing the > transfer. That was to be expected, 'worker.run' doesn't start a new thread but just runs the run method of the thread object in the current thread. This does show that the actual FTP code is correct though. Could you try to create a small demo program that has the same problem (such as a program with a single button that triggers a download from some public FTP site)? I cannot determine what's going on here from your description, it seems to me that your code should work even though it obviously doesn't. Another thing you might try to check if the problem is Cocoa related is to create a command-line tool that calls worker.start to start the FTP transaction in a background thread (don't forget to add code that waits until the background thread is done). Ronald > > > On Tue, Sep 8, 2009 at 10:49 AM, Rob <rob...@gm...> wrote: > 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 > > > > -- > http://robrohan.com > http://twitter.com/robrohan > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |