[Python] BadStatusLine exception using Google Custom Search

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

johnie104
Posts: 248
Joined: Tue Jan 08, 2008 6:44 pm UTC
Contact:

[Python] BadStatusLine exception using Google Custom Search

Postby johnie104 » Mon Oct 28, 2013 2:04 pm UTC

Hey guys,

Can you help me where StackOverflow doesn't help me:
StackOverflow Link
So yeah, I get this exception quite randomly. It may be related to unicode but I'm not sure. I can't find anyone else having this problem and my question doesn't have any responses.
Does anyone know how to fix this, or who I would need to contact or what I would need to try to get this fixed?
Signature removed because of it's blinding awesomeness.

User avatar
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: [Python] BadStatusLine exception using Google Custom Sea

Postby phlip » Tue Oct 29, 2013 4:53 am UTC

Are you able to capture what's actually being sent over the wire? Does it use HTTP or HTTPS? If it's just HTTP, then you should be able to just capture the stream with something like Wireshark, and take a look to see if it's just that Google is giving a weird response, or if it's giving something that httplib can't figure out...

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

johnie104
Posts: 248
Joined: Tue Jan 08, 2008 6:44 pm UTC
Contact:

Re: [Python] BadStatusLine exception using Google Custom Sea

Postby johnie104 » Tue Oct 29, 2013 7:43 pm UTC

phlip wrote:Are you able to capture what's actually being sent over the wire? Does it use HTTP or HTTPS? If it's just HTTP, then you should be able to just capture the stream with something like Wireshark, and take a look to see if it's just that Google is giving a weird response, or if it's giving something that httplib can't figure out...


This is one of the urls that produced a crash (This is what was put in my log by apiclient.discovery):

Code: Select all

https://www.googleapis.com/customsearch/v1?dateRestrict=d1&num=10&safe=high&q=brand+Bevrijding%29+Groot+Bollerweg+Venlo&cx=010192606796870468691%3Aulwcdwfbd10&lr=lang_nl&key=AIzaSyCj-6T-nO8ScCy50Tjy_4NLN2mHMHypCIk&alt=json


After it crashed I immediately tried to open it in Chrome which worked perfectly and showed no weird stuff or warnings.
If I perform the same search now (a week later) it doesn't crash my program. So I really think it has to do with the specific items that are returned.
I have no idea how to fix this and it seems like there is no one else who has this problem (googling 'python google custom search' returns surprisingly few helpful results).

Btw, if it is relevant: The code is executed in a Pyqt QThread and most of the time isn't the only URL I'm requesting at the moment. I don't know of any conflicts this could created, but you never know (If I recall correctly I have managed to reproduce this problem in a non-threading environment).
Signature removed because of it's blinding awesomeness.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 10 guests