BUG/TST: catch socket.error in py2/3.2 and ConnectionError in py3.3 #3985

Merged
merged 2 commits into from Jun 26, 2013

Conversation

Projects
None yet
3 participants
Member

cpcloud commented Jun 21, 2013

closes #3982.

cpcloud was assigned Jun 21, 2013

Member

cpcloud commented Jun 21, 2013

this passes travis but that doesn't really tell us that much...since the errors from #3982 are occurring intermittently...

Member

cpcloud commented Jun 21, 2013

also it skips when i remove my connection...but i'm still not sure if that's enough

Member

cpcloud commented Jun 23, 2013

strange that it only happens on 3.2...trying to think of what itcould be @jreback @jtratner any ideas?
https://travis-ci.org/cpcloud/pandas/jobs/8322345

Contributor

jtratner commented Jun 23, 2013

Is socket.error a subclass of IOError in 3.2? Wasn't clear on the
resolution to this previously...

Member

cpcloud commented Jun 23, 2013

yep it is.

Member

cpcloud commented Jun 23, 2013

it's possible that this might be the problem and the solution

Member

cpcloud commented Jun 23, 2013

sigh probably a simple context manager will fix this....the resp is not being closed...same for google

Contributor

jtratner commented Jun 23, 2013

I can write something up this week, do you want me to take it on?

Member

cpcloud commented Jun 23, 2013

no it's fine i can do it, won't take that long. i'll write something on the wiki too showing how to use context managers with resources that don't implement the context manager protocol.

while it may not be too big of a deal to not close a file (or close url resource) when one is working in the shell, it's quite another to leave resources open in library code, especially since python makes it so easy to automatically close a file.

Contributor

jtratner commented Jun 23, 2013

can you use urlopen in a with statement? If so, that makes it incredibly
simple....

On Sat, Jun 22, 2013 at 11:39 PM, Phillip Cloud notifications@github.comwrote:

no it's fine i can do it, won't take that long. i'll write something on
the wiki too showing how to use context managers with resources that don't
implement the context manager protocol.

while it may not be too big of a deal to not close a file (or close url
resource) when one is working in the shell, it's quite another to leave
resources open in library code, especially since python makes it _so_easy to automatically close a file.


Reply to this email directly or view it on GitHubhttps://github.com/pydata/pandas/pull/3985#issuecomment-19868544
.

Member

cpcloud commented Jun 23, 2013

Yep but in Python 2 you must use for example, with contextlib.closing(urlopen(url)) as response since url objects don't implement the context manager protocol in Python 2 in Python 3 they work fine with a regular with statement

Contributor

jtratner commented Jun 23, 2013

good to know - learned something today :)

On Sun, Jun 23, 2013 at 9:29 AM, Phillip Cloud notifications@github.comwrote:

Yep but in Python 2 you must use for example, with
contextlib.closing(urlopen(url)) as response since url objects don't
implement the context manager protocol in Python 2 in Python 3 they work
fine with a regular with statement


Reply to this email directly or view it on GitHubhttps://github.com/pydata/pandas/pull/3985#issuecomment-19873954
.

Contributor

jreback commented Jun 23, 2013

this fix the problem?

Member

cpcloud commented Jun 23, 2013

close in favor of #4002 .

cpcloud closed this Jun 23, 2013

Contributor

jreback commented Jun 26, 2013

since you moved your data fixes to 0.13.....any chance of reviving fixing these network test issues? or too much work?

Member

cpcloud commented Jun 26, 2013

i could just peel off the commit from the clean up and use that

Contributor

jreback commented Jun 26, 2013

maybe do that these netwok tests failing too much

cpcloud reopened this Jun 26, 2013

Member

cpcloud commented Jun 26, 2013

let me get rid of some of these merge commits

Member

cpcloud commented Jun 26, 2013

whoops that zf context won't pass hold on

Member

cpcloud commented Jun 26, 2013

no wonder there are all these reset connection errors there are a ton of sockets to yahoo finance left open

Member

cpcloud commented Jun 26, 2013

will merge after passing...just added docs

@cpcloud cpcloud added a commit that referenced this pull request Jun 26, 2013

@cpcloud cpcloud Merge pull request #3985 from cpcloud/network-socket-errno-thing
BUG/TST: catch socket.error in py2/3.2 and ConnectionError in py3.3
f09a03c

@cpcloud cpcloud merged commit f09a03c into pandas-dev:master Jun 26, 2013

cpcloud deleted the cpcloud:network-socket-errno-thing branch Jun 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment