from gevent import monkey
monkey.patch_socket()
client = boto3.client('s3')
transfer = S3Transfer(client)
transfer.upload_file(temp.name, settings.AWS_BUCKET_NAME,
key, extra_args={'ACL': 'public-read'})
File "/usr/local/lib/python2.7/site-packages/boto3/s3/transfer.py", line 639, in upload_file
self._put_object(filename, bucket, key, callback, extra_args)
File "/usr/local/lib/python2.7/site-packages/boto3/s3/transfer.py", line 649, in _put_object
**extra_args)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 301, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 387, in _make_api_call
operation_model, request_dict)
File "/usr/local/lib/python2.7/site-packages/botocore/endpoint.py", line 117, in make_request
return self._send_request(request_dict, operation_model)
File "/usr/local/lib/python2.7/site-packages/botocore/endpoint.py", line 146, in _send_request
success_response, exception):
File "/usr/local/lib/python2.7/site-packages/botocore/endpoint.py", line 219, in _needs_retry
caught_exception=caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/hooks.py", line 226, in emit
return self._emit(event_name, kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/hooks.py", line 209, in _emit
response = handler(**kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 250, in __call__
caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 265, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 313, in __call__
caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 222, in __call__
return self._check_caught_exception(attempt_number, caught_exception)
File "/usr/local/lib/python2.7/site-packages/botocore/retryhandler.py", line 355, in _check_caught_exception
raise caught_exception
ValueError: do_handshake_on_connect should not be specified for non-blocking sockets
There is a note about it in eventlet as well:
https://github.com/eventlet/eventlet/blob/master/eventlet/green/ssl.py#L64-L65
Nevermind, when patching the socket you also need to patch_ssl() which fixes it.
from gevent import monkey
monkey.patch_socket()
monkey.patch_ssl()
thank you very much,i got the method to solve the problem. @aventurella
Most helpful comment
Nevermind, when patching the socket you also need to patch_ssl() which fixes it.