Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53541
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'explicitly': 0.05; 'subject:Python': 0.06; 'granted,': 0.07; 'layers': 0.07; 'modified': 0.07; 'skip:u 30': 0.07; 'socket': 0.07; 'urllib2': 0.07; 'attack.': 0.09; 'parameter': 0.09; 'path)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '2.7': 0.14; 'windows': 0.15; 'apply\\n': 0.16; 'bit.': 0.16; 'cwd': 0.16; 'ftplib': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'seconds,': 0.16; 'seconds.': 0.16; 'self.timeout': 0.16; 'timeout': 0.16; 'tracker,': 0.16; 'wrote:': 0.18; '(not': 0.18; 'looked': 0.18; 'obviously': 0.18; 'file,': 0.19; 'properly': 0.19; 'restrictions': 0.19; 'working.': 0.19; 'work,': 0.20; 'help.': 0.21; 'command': 0.22; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'imposed': 0.24; 'passes': 0.24; 'tue': 0.24; 'connected': 0.24; 'login': 0.25; 'recognized': 0.26; 'skip:" 40': 0.26; 'second': 0.26; 'pass': 0.26; 'code:': 0.26; 'skip:" 20': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'host': 0.29; 'rest': 0.29; 'skip:- 40': 0.29; 'url:bugs': 0.29; 'raise': 0.29; "doesn't": 0.30; 'mode': 0.30; 'reaches': 0.30; "i'm": 0.30; 'gives': 0.31; 'code': 0.31; 'comments': 0.31; "skip:' 10": 0.31; 'securities': 0.31; 'file': 0.32; 'linux': 0.33; 'url:python': 0.33; 'running': 0.33; 'call.': 0.33; 'period': 0.33; 'connection': 0.35; 'problem.': 0.35; 'skip:u 20': 0.35; 'but': 0.35; 'there': 0.35; 'consistent': 0.36; "didn't": 0.36; 'url:org': 0.36; 'seconds': 0.37; 'list': 0.37; 'server': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'system.': 0.39; 'received:org': 0.40; 'how': 0.40; 'days': 0.60; 'skip:u 10': 0.60; 'read': 0.60; 'commands': 0.60; 'increased': 0.61; 'completed': 0.61; 'john': 0.61; 'received:173': 0.61; 'first': 0.61; 'times': 0.62; 'exchange': 0.63; 'such': 0.63; '2000': 0.65; 'direct': 0.67; 'skip:r 40': 0.68; 'u.s.': 0.71; '(open': 0.84; 'commission.': 0.84; 'cuts': 0.84; 'presumably': 0.84; 'received:fios.verizon.net': 0.84; 'stat': 0.84; 'subject:effective': 0.84; 'connection,': 0.95 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Python FTP timeout value not effective |
| Date | Mon, 02 Sep 2013 20:04:59 -0400 |
| References | <l02io1$kug$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-75-251-66.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
| In-Reply-To | <l02io1$kug$1@dont-email.me> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.524.1378166719.19984.python-list@python.org> (permalink) |
| Lines | 88 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1378166719 news.xs4all.nl 15981 [2001:888:2000:d::a6]:42095 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53541 |
Show key headers only | View raw
On 9/2/2013 1:43 PM, John Nagle wrote:
> I'm reading files from an FTP server at the U.S. Securities and
> Exchange Commission. This code has been running successfully for
> years. Recently, they imposed a consistent connection delay
> of 20 seconds at FTP connection, presumably because they're having
> some denial of service attack. Python 2.7 urllib2 doesn't
> seem to use the timeout specified. After 20 seconds, it
> gives up and times out.
>
> Here's the traceback:
>
> Internal error in EDGAR update: <urlopen error ftp error: [Errno 110]
> Connection timed out>
> ....
> File "./edgar/edgarnetutil.py", line 53, in urlopen
>
> File "/opt/python27/lib/python2.7/socket.py", line 571, in
> create_connection
...
> raise err
> URLError: <urlopen error ftp error: [Errno 110] Connection timed out>
>
> Periodic update completed in 21.1 seconds.
> ----------------------------------------------
>
> Here's the relevant code:
>
> TIMEOUTSECS = 60 ## give up waiting for server after 60 seconds
> ...
> def urlopen(url,timeout=TIMEOUTSECS) :
> if url.endswith(".gz") : # gzipped file, must decompress first
> nd = urllib2.urlopen(url,timeout=timeout) # get connection
> ... # (NOT .gz FILE, DOESN'T TAKE THIS PATH)
> else :
> return(urllib2.urlopen(url,timeout=timeout)) # (OPEN FAILS)
I looked at the 3.3 urllib.retrieve.urlopen code and timeout is passed
through a couple of layers but is it hard to see if it reaches the
socket connection call. I would also try python3.3 as timeout may have
been changed a bit.
There are some 'timeout' issues on the tracker, such as
http://bugs.python.org/issue4079
http://bugs.python.org/issue18417
but these do not obviously apply to an explicitly passed timeout
I would also try using ftplib, which cuts out lots of the general
purpose layers urlopen. FTP.__init__ stores timeout in self.timeout and
calls connect(), which passes self.timeout to socket.create_connection.
>>> import ftplib
>>> ftp = ftplib.FTP("ftp.sec.gov")
>>> ftp.login()
'230-Anonymous access granted, restrictions apply\n \n Please read the
file README.txt\n230 it was last modified on Tue Aug 15 14:29:31 2000
- 4765 days ago'
>>> ftp.sendcmd('help')
"214-The following commands are recognized (* =>'s unimplemented):\n CWD
XCWD CDUP XCUP SMNT* QUIT PORT PASV \n EPRT
EPSV ALLO* RNFR RNTO DELE MDTM RMD \n XRMD MKD
XMKD PWD XPWD SIZE SYST HELP \n NOOP FEAT
OPTS AUTH* CCC* CONF* ENC* MIC* \n PBSZ* PROT* TYPE
STRU MODE RETR STOR STOU \n APPE REST ABOR
USER PASS ACCT* REIN* LIST \n NLST STAT SITE MLSD
MLST \n214 Direct comments to root@clone11.sec.gov"
I tried to read 'README.txt but I do not know how to use the commands or
local FTP methods.
> TIMEOUTSECS used to be 20 seconds, and I increased it to 60. It didn't
> help.
>
> This isn't an OS problem. The above traceback was on a Linux system.
> On Windows 7, it fails with
>
> "URLError: <urlopen error ftp error: [Errno 10060] A connection attempt
> failed because the connected party did not properly respond after a
> period of time, or established connection failed because connected host
> has failed to respond>"
>
> But in both cases, the command line FTP client will work, after a
> consistent 20 second delay before the login prompt. So the
> Python timeout parameter isn't working.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Python FTP timeout value not effective John Nagle <nagle@animats.com> - 2013-09-02 10:43 -0700 Re: Python FTP timeout value not effective David Bolen <db3l.net@gmail.com> - 2013-09-02 18:00 -0400 Re: Python FTP timeout value not effective Chris Angelico <rosuav@gmail.com> - 2013-09-03 08:35 +1000 Re: Python FTP timeout value not effective Terry Reedy <tjreedy@udel.edu> - 2013-09-02 20:04 -0400
csiph-web