GithubHelp home page GithubHelp logo

Comments (4)

Visgean avatar Visgean commented on August 18, 2024

here is my implementation: Visgean/facebook-sdk@f8f05f9

from facebook-sdk.

martey avatar martey commented on August 18, 2024

This is a positive change, but will break Python 2.5 support. I do not think very many people are still using 2.5, though.

from facebook-sdk.

Visgean avatar Visgean commented on August 18, 2024

http://stackoverflow.com/questions/2084782/timeout-for-urllib2-urlopen-in-pre-python-2-6-versions here I can see that there is another solution, it might be better to have this in init:

def __init__(self, access_token=None, timeout=1):
        self.access_token = access_token
        socket.setdefaulttimeout(timeout)

the question is what should be the default timeout - I have look to my facebook insights and average FQL takes about 84ms to process... but of course that is only time on their servers.. And it does not brake the <2.6 compatibility

from facebook-sdk.

martey avatar martey commented on August 18, 2024

Maybe something like:

def __init__(self, access_token=None, timeout=None):
    self.access_token = access_token
    self.timeout = timeout

# Extraneous code redacted...

def request(self, path, args=None, post_args=None):
    # Extraneous code redacted...
    try:
        file = urllib2.urlopen("https://graph.facebook.com/" + path + "?" +
                urllib.urlencode(args), post_data, timeout=self.timeout)
    except TypeError:
        # We are running in Python 2
        if self.timeout:
            socket.setdefaulttimeout(self.timeout)
            urllib2.urlopen("https://graph.facebook.com/" + path + "?" +
                    urllib.urlencode(args), post_data)

This would only allow to not have a timeout if they did not want to, would only set the default socket timeout if we are running in Python 2 and a timeout has been set (which is important because it can break other applications), and not break backwards compatibility for people currently using the application.

@Visgean, if you submit a pull request with these changes, I will approve it and roll out a new version to PyPi.

from facebook-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.