Commit bcce6fb1 authored by Jérome Perrin's avatar Jérome Perrin

ERP5ExternalOauth2ExtractionPlugin: use facebook.GraphAPI timeout argument

Instead of temporarily changing the global timeout, which can impact
other parts of the system and which is not free from race conditions (
another thread might have changed the timeout when socket.getdefaulttimeout()
is called and then we restore a wrong default timeout).
parent 19645b96
......@@ -39,7 +39,6 @@ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager
from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE
import time
import socket
from six.moves import urllib
import json
from zLOG import LOG, ERROR, INFO
......@@ -234,14 +233,8 @@ def getFacebookUserEntry(token):
'No facebook module, install facebook-sdk package. '
'Authentication disabled.')
return None
timeout = socket.getdefaulttimeout()
args = {'fields' : 'id,name,email', }
try:
# require really fast interaction
socket.setdefaulttimeout(5)
facebook_entry = facebook.GraphAPI(token).get_object("me", **args)
finally:
socket.setdefaulttimeout(timeout)
facebook_entry = facebook.GraphAPI(token, timeout=5).get_object("me", **args)
user_entry = {}
if facebook_entry is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment