Announcement

Collapse
No announcement yet.

what happened with FTP?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • what happened with FTP?

    Hi,
    I have a PremierWave XN.
    Recently I'm making a simple application which uploads file from PW XN to a FTP server. My PW XN is working as ftp client. I use the python standard library ftplib.

    It works fine.

    However, I find a problem. When the ftp server is not able to reached (for example its servers is down, or network connection between server and client is down and etc.), it can't raise exception and quit.

    Here is a snippets of my testing code for logging the exception information when ftp server is not able to reach.

    #-----------------------------------------------
    import logging
    from ftplib import FTP

    logger = logging.getLogger(__name__)
    handler = logging.FileHandler('test.txt')
    logger.addHandler(handler)

    try:
    FTP('192.168.1.141')
    except Exception, e:
    logger.exception('Error')
    #---------------------------------------------

    When I run this script on my PC, it log the TraceBack information to a file test.txt
    I upload it to PW XN, and run it. (I shut down the server of course)
    The script create a test.txt at the directory. But it is empty.
    The python process is not end, when I go to check it in the web manager.
    Does someone have any idea what is going on here? Is there any hardware level issue for PW XN?

  • #2
    What happens if you add a timeout to the ftp call?

    See here:
    https://docs.python.org/2.7/library/ftplib.html

    Comment


    • #3
      Hi Mariano,

      Yes I made a stupid mistake. It is still trying to reach the server while I am rush to check whether it raise the exception. Thanks for your reply.
      After simply add a timeout for the ftp call, my problem has solved.

      Cheers!

      Comment

      Working...
      X