Commit 3d69a025 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 18701c5a
Pipeline #21091 failed with stage
in 0 seconds
......@@ -39,7 +39,6 @@ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager
from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE
import time
import socket
import httplib
import urllib
import json
......@@ -235,14 +234,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