Boto3 timeout troubleshooting - python

I am trying to troubleshoot a situation.
I am initiating a Boto3 client like this:
s3_client = boto3.client('s3')
Then I am iterating over a number of files and uploading them using:
s3_client.upload_file()
My problem is that every now and then I see it pausing for 60 seconds and then continuing normally.
I've tried reducing the timeout value and the error I seem to be getting is:
botocore.exceptions.ConnectTimeoutError
or
urllib3.exceptions.ConnectTimeoutError
If I leave it at 60, eventually it succeeds and I don't get any errors.
My question is, this error means that when executing upload_file, it tried to send a put request to the server and the server didn't respond to that request?
When initiating the client, is any connection established that could be lost or that's simply only storing the credentials and it's irrelevant to this issue?
Many thanks.
Update: Adding more detailed logs:
CRITICAL Connect timeout
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 439, in send
urllib_response = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 507, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 719, in reraise
raise value
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 1012, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 353, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError
During handling of the above exception, another exception occurred:
File "/home/user/.local/lib/python3.10/site-packages/boto3/s3/inject.py", line 143, in upload_file
return transfer.upload_file(
File "/home/user/.local/lib/python3.10/site-packages/boto3/s3/transfer.py", line 288, in upload_file
future.result()
File "/home/user/.local/lib/python3.10/site-packages/s3transfer/futures.py", line 103, in result
return self._coordinator.result()
File "/home/user/.local/lib/python3.10/site-packages/s3transfer/futures.py", line 266, in result
raise self._exception
File "/home/user/.local/lib/python3.10/site-packages/s3transfer/tasks.py", line 139, in __call__
return self._execute_main(kwargs)
File "/home/user/.local/lib/python3.10/site-packages/s3transfer/tasks.py", line 162, in _execute_main
return_value = self._main(**kwargs)
File "/home/user/.local/lib/python3.10/site-packages/s3transfer/upload.py", line 758, in _main
client.put_object(Bucket=bucket, Key=key, Body=body, **extra_args)
File "/home/user/.local/lib/python3.10/site-packages/botocore/client.py", line 415, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/user/.local/lib/python3.10/site-packages/botocore/client.py", line 731, in _make_api_call
http, parsed_response = self._make_request(
File "/home/user/.local/lib/python3.10/site-packages/botocore/client.py", line 751, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "/home/user/.local/lib/python3.10/site-packages/botocore/endpoint.py", line 107, in make_request
return self._send_request(request_dict, operation_model)
File "/home/user/.local/lib/python3.10/site-packages/botocore/endpoint.py", line 183, in _send_request
while self._needs_retry(attempts, operation_model, request_dict,
File "/home/user/.local/lib/python3.10/site-packages/botocore/endpoint.py", line 305, in _needs_retry
responses = self._event_emitter.emit(
File "/home/user/.local/lib/python3.10/site-packages/botocore/hooks.py", line 358, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "/home/user/.local/lib/python3.10/site-packages/botocore/hooks.py", line 229, in emit
return self._emit(event_name, kwargs)
File "/home/user/.local/lib/python3.10/site-packages/botocore/hooks.py", line 212, in _emit
response = handler(**kwargs)
File "/home/user/.local/lib/python3.10/site-packages/botocore/retryhandler.py", line 194, in __call__
if self._checker(**checker_kwargs):
File "/home/user/.local/lib/python3.10/site-packages/botocore/retryhandler.py", line 267, in __call__
should_retry = self._should_retry(attempt_number, response,
File "/home/user/.local/lib/python3.10/site-packages/botocore/retryhandler.py", line 294, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/home/user/.local/lib/python3.10/site-packages/botocore/retryhandler.py", line 333, in __call__
checker_response = checker(attempt_number, response,
File "/home/user/.local/lib/python3.10/site-packages/botocore/retryhandler.py", line 233, in __call__
return self._check_caught_exception(
File "/home/user/.local/lib/python3.10/site-packages/botocore/retryhandler.py", line 376, in _check_caught_exception
raise caught_exception
File "/home/user/.local/lib/python3.10/site-packages/botocore/endpoint.py", line 249, in _do_get_response
http_response = self._send(request)
File "/home/user/.local/lib/python3.10/site-packages/botocore/endpoint.py", line 321, in _send
return self.http_session.send(request)
File "/home/user/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 472, in send
raise ConnectTimeoutError(endpoint_url=request.url, error=e)

The default boto3 retry mode (Legacy) doesn't properly handle a number of errors/exceptions, including RequestThrottled, PriorRequestNotComplete, ConnectionError and BandwidthLimitExceeded. It can manifest as very intermittent problems with long delays and repeated connection failures. You'll likely be better off using the Standard retry mode instead, which also has an exponential backoff.
import boto3
from botocore.client import Config as BotoConfig
TIMEOUT = 3
config = BotoConfig(connect_timeout=TIMEOUT, retries={"mode": "standard"})
client = boto3.client("s3", config=config)

Related

An existing connection was forcibly closed by the remote host in discord.py bot

basically I was using discord.py and another modules when I got this error
when I go this requests connection problem how to solve it?
I was using python-aternos library
it uses cloudscraper,requests,urlib
I don't know what to do saw many posts but most of answers where to change the headings but yeah I want another way like to add a new connection I don't know if that possible can anyone tell me?
Traceback (most recent call last):
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 703, in
urlopen
httplib_response = self._make_request(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 386, in
_make_request
self._validate_conn(conn)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\cloudscraper\__init__.py", line 98, in wrap_socket
return self.ssl_context.orig_wrap_socket(*args, **kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1071, in _create
self.do_handshake()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 787, in
urlopen
retries = retries.increment(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\retry.py", line 550, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
raise value.with_traceback(tb)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 703, in
urlopen
httplib_response = self._make_request(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 386, in
_make_request
self._validate_conn(conn)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\cloudscraper\__init__.py", line 98, in wrap_socket
return self.ssl_context.orig_wrap_socket(*args, **kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1071, in _create
self.do_handshake()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\Dell\OneDrive\Desktop\Python\aternos_v3\main.py", line 221, in <module>
asyncio.run(main())
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "c:\Users\Dell\OneDrive\Desktop\Python\aternos_v3\main.py", line 218, in main
servers = await get_servers()
File "c:\Users\Dell\OneDrive\Desktop\Python\aternos_v3\server_opener.py", line 13, in get_servers
servs = aternos.list_servers()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\python_aternos\atclient.py", line 326, in list_servers
self.refresh_servers(servers)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\python_aternos\atclient.py", line 352, in refresh_servers
srv = AternosServer(servid, self.atconn)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\python_aternos\atserver.py", line 69, in
__init__
self.fetch()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\python_aternos\atserver.py", line 74, in
fetch
servreq = self.atserver_request(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\python_aternos\atserver.py", line 231, in atserver_request
return self.atconn.request_cloudflare(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\python_aternos\atconnect.py", line 250, in request_cloudflare
req = sendreq(
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\cloudscraper\__init__.py", line 257, in request
self.perform_request(method, url, *args, **kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\cloudscraper\__init__.py", line 190, in perform_request
return super(CloudScraper, self).request(method, url, *args, **kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 547, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
read many sits but none of them was useful can anyone help?

PermissionError: [Errno 13] Permission denied with Binance API (python)

I'm running trading bots written in python in VS Code on mac, trading at binance exchange.
Unfortunately I get sporadic errors when the bot is placing orders, respectively connect via websocket. I really can't explain what's going on because the bots are running well for one or two days and then suddenly this error is disrupting the strategy, because it causes that orders are not cancelled anymore when they should leading to unsecured trades (without stop).
Message: 'Starting new HTTPS connection (%d): %s:%s'
Arguments: (1, 'fapi.binance.com', 443)
--- Logging error ---
Traceback (most recent call last):
File "/Users/username/anaconda3/lib/python3.7/logging/__init__.py", line 1038, in emit
self.flush()
File "/Users/username/anaconda3/lib/python3.7/logging/__init__.py", line 1018, in flush
self.stream.flush()
PermissionError: [Errno 13] Permission denied
Call stack:
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/engine_LinReg.py", line 102, in execute
execution_short_ETH.main()
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/execution_short_ETH.py", line 22, in main
response_tradelist = sr.send_signed_request('GET', '/fapi/v1/userTrades', params)
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/send_requests_ETH.py", line 49, in send_signed_request
response = dispatch_request(http_method)(**params)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 393, in _make_request
httplib_response.length)
Message: '%s://%s:%s "%s %s %s" %s %s'
Arguments: ('https', 'fapi.binance.com', 443, 'GET', '/fapi/v1/userTrades?timestamp=1630094893528&signature=456f8b3cf34a36ad257114d4e8a7ca31d43c27ddb8ad8296bc7e3d3d416f9145', 'HTTP/1.1', 200, None)
--- Logging error ---
Traceback (most recent call last):
File "/Users/username/anaconda3/lib/python3.7/logging/__init__.py", line 1038, in emit
self.flush()
File "/Users/username/anaconda3/lib/python3.7/logging/__init__.py", line 1018, in flush
self.stream.flush()
PermissionError: [Errno 13] Permission denied
Call stack:
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/engine_LinReg.py", line 102, in execute
execution_short_ETH.main()
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/execution_short_ETH.py", line 34, in main
#response = sr.send_public_request('/fapi/v1/ticker/24hr?symbol='+symbol)
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/send_requests_ETH.py", line 59, in send_public_request
response = dispatch_request('GET')(url=url)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 588, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 248, in _get_conn
return conn or self._new_conn()
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 813, in _new_conn
self.num_connections, self.host, self.port or "443")
Message: 'Starting new HTTPS connection (%d): %s:%s'
Arguments: (1, 'fapi.binance.com', 443)
--- Logging error ---
Traceback (most recent call last):
File "/Users/username/anaconda3/lib/python3.7/logging/__init__.py", line 1038, in emit
self.flush()
File "/Users/username/anaconda3/lib/python3.7/logging/__init__.py", line 1018, in flush
self.stream.flush()
PermissionError: [Errno 13] Permission denied
Call stack:
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/engine_LinReg.py", line 102, in execute
execution_short_ETH.main()
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/execution_short_ETH.py", line 34, in main
#response = sr.send_public_request('/fapi/v1/ticker/24hr?symbol='+symbol)
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/send_requests_ETH.py", line 59, in send_public_request
response = dispatch_request('GET')(url=url)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 393, in _make_request
httplib_response.length)
Message: '%s://%s:%s "%s %s %s" %s %s'
Arguments: ('https', 'fapi.binance.com', 443, 'POST', '/fapi/v1/order?symbol=ETHUSDT&side=SELL&type=MARKET&quantity=0.01&newOrderRespType=RESULT&timestamp=1630094894451&signature=67252a93834cedde133ad0fa62683126a9ca583147fffcf2cefbdff071fa4ce3', 'HTTP/1.1', 200, None)
--- Logging error ---
Traceback (most recent call last):
File "/Users/username/anaconda3/lib/python3.7/logging/__init__.py", line 1038, in emit
self.flush()
File "/Users/username/anaconda3/lib/python3.7/logging/__init__.py", line 1018, in flush
self.stream.flush()
PermissionError: [Errno 13] Permission denied
Call stack:
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 885, in _bootstrap
self._bootstrap_inner()
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/username/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/engine_LinReg.py", line 102, in execute
execution_short_ETH.main()
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/execution_short_ETH.py", line 58, in main
TP = int(entryPrice-settings_ETH.TP)
File "/Users/username/Workfiles/python/binance/vs_binance_algo/ETH_LinReg/send_requests_ETH.py", line 49, in send_signed_request
response = dispatch_request(http_method)(**params)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/username/anaconda3/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 588, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 248, in _get_conn
return conn or self._new_conn()
File "/Users/username/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 813, in _new_conn
self.num_connections, self.host, self.port or "443")
...and so on...
I can't find anything in the dev.binance forum in this regard (and they are anyway not very helpful).
What does this error mean?
My intuition is an imported module try to create a log file with logging module and raise a PermissionError.
Try to disable logging:
import logging.config
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': True,
})

django.db.utils.DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread - with celery beat and dbbackup

I am writing a code to take frequent backups of our database to dropbox. The following is my tasks.py that has a test code to execute a Django management command management.call_command('dbbackup', interactive=False) every 1 minute. But I am encountering the error django.db.utils.DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 140423029811616 and this is thread id 140422957233632..
tasks.py
from __future__ import absolute_import, unicode_literals
from myproject.celery import app
from celery.utils.log import get_task_logger
from celery.schedules import crontab
from django.core import management
#app.task
def db_backup_to_dropbox():
management.call_command('dbbackup', interactive=False)
app.conf.beat_schedule = {
'backup-every-second': {
'task': 'core.tasks.db_backup_to_dropbox',
'schedule': crontab(minute='*/1'),
'args': (),
},
}
Traceback from celery.log
[2020-07-25 16:24:00,050: INFO/MainProcess] Received task: core.tasks.db_backup_to_dropbox[a34653fe-a3c6-4259-a98d-7613c5f3446c]
[2020-07-25 16:24:00,054: INFO/MainProcess] Backing Up Database: myproject
[2020-07-25 16:24:00,213: INFO/MainProcess] Writing file to default-myserver-loc1-2020-07-25-162400.dump
[2020-07-25 16:24:00,215: INFO/MainProcess] Request to files/get_metadata
[2020-07-25 16:24:00,287: ERROR/MainProcess] RecursionError: maximum recursion depth exceeded while calling a Python object
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/utils.py", line 118, in wrapper
func(*args, **kwargs)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/management/commands/dbbackup.py", line 61, in handle
self._save_new_backup(database)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/management/commands/dbbackup.py", line 88, in _save_new_backup
self.write_to_storage(outputfile, filename)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/management/commands/_base.py", line 88, in write_to_storage
self.storage.write_file(file, path)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/storage.py", line 82, in write_file
self.storage.save(name=filename, content=filehandle)
File "/myproject/venv/lib/python3.8/site-packages/django/core/files/storage.py", line 51, in save
name = self.get_available_name(name, max_length=max_length)
File "/myproject/venv/lib/python3.8/site-packages/django/core/files/storage.py", line 82, in get_available_name
while self.exists(name) or (max_length and len(name) > max_length):
File "/myproject/venv/lib/python3.8/site-packages/storages/backends/dropbox.py", line 93, in exists
return bool(self.client.files_get_metadata(self._full_path(name)))
File "/myproject/venv/lib/python3.8/site-packages/dropbox/base.py", line 1682, in files_get_metadata
r = self.request(
File "/myproject/venv/lib/python3.8/site-packages/dropbox/dropbox.py", line 313, in request
res = self.request_json_string_with_retry(host,
File "/myproject/venv/lib/python3.8/site-packages/dropbox/dropbox.py", line 463, in request_json_string_with_retry
return self.request_json_string(host,
File "/myproject/venv/lib/python3.8/site-packages/dropbox/dropbox.py", line 559, in request_json_string
r = self._session.post(url,
File "/myproject/venv/lib/python3.8/site-packages/requests/sessions.py", line 578, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/myproject/venv/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/myproject/venv/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/myproject/venv/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/myproject/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen httplib_response = self._make_request(
File "/myproject/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "/myproject/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
conn.connect()
File "/myproject/venv/lib/python3.8/site-packages/urllib3/connection.py", line 343, in connect
self.ssl_context = create_urllib3_context(
File "/myproject/venv/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 277, in create_urllib3_context
context.options |= options
File "/usr/lib/python3.8/ssl.py", line 602, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/lib/python3.8/ssl.py", line 602, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/lib/python3.8/ssl.py", line 602, in options
super(SSLContext, SSLContext).options.__set__(self, value)
[Previous line repeated 460 more times]
[2020-07-25 16:24:00,325: ERROR/MainProcess] Task core.tasks.db_backup_to_dropbox[a34653fe-a3c6-4259-a98d-7613c5f3446c] raised unexpected: DatabaseError("DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 140423029811616 and this is thread id 140422957233632.")
Traceback (most recent call last):
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/utils.py", line 118, in wrapper
func(*args, **kwargs)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/management/commands/dbbackup.py", line 61, in handle
self._save_new_backup(database)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/management/commands/dbbackup.py", line 88, in _save_new_backup
self.write_to_storage(outputfile, filename)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/management/commands/_base.py", line 88, in write_to_storage
self.storage.write_file(file, path)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/storage.py", line 82, in write_file
self.storage.save(name=filename, content=filehandle)
File "/myproject/venv/lib/python3.8/site-packages/django/core/files/storage.py", line 51, in save
name = self.get_available_name(name, max_length=max_length)
File "/myproject/venv/lib/python3.8/site-packages/django/core/files/storage.py", line 82, in get_available_name
while self.exists(name) or (max_length and len(name) > max_length):
File "/myproject/venv/lib/python3.8/site-packages/storages/backends/dropbox.py", line 93, in exists
return bool(self.client.files_get_metadata(self._full_path(name)))
File "/myproject/venv/lib/python3.8/site-packages/dropbox/base.py", line 1682, in files_get_metadata
r = self.request(
File "/myproject/venv/lib/python3.8/site-packages/dropbox/dropbox.py", line 313, in request
res = self.request_json_string_with_retry(host,
File "/myproject/venv/lib/python3.8/site-packages/dropbox/dropbox.py", line 463, in request_json_string_with_retry
return self.request_json_string(host,
File "/myproject/venv/lib/python3.8/site-packages/dropbox/dropbox.py", line 559, in request_json_string
r = self._session.post(url,
File "/myproject/venv/lib/python3.8/site-packages/requests/sessions.py", line 578, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/myproject/venv/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/myproject/venv/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/myproject/venv/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/myproject/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen httplib_response = self._make_request(
File "/myproject/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "/myproject/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
conn.connect()
File "/myproject/venv/lib/python3.8/site-packages/urllib3/connection.py", line 343, in connect
self.ssl_context = create_urllib3_context(
File "/myproject/venv/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 277, in create_urllib3_context
context.options |= options
File "/usr/lib/python3.8/ssl.py", line 602, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/lib/python3.8/ssl.py", line 602, in options
super(SSLContext, SSLContext).options.__set__(self, value)
File "/usr/lib/python3.8/ssl.py", line 602, in options
super(SSLContext, SSLContext).options.__set__(self, value)
[Previous line repeated 460 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/myproject/venv/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
R = retval = fun(*args, **kwargs)
File "/myproject/venv/lib/python3.8/site-packages/celery/app/trace.py", line 704, in __protected_call__
return self.run(*args, **kwargs)
File "/myproject/myproject/core/tasks.py", line 11, in db_backup_to_dropbox
management.call_command('dbbackup', interactive=False)
File "/myproject/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 168, in call_command
return command.execute(*args, **defaults)
File "/myproject/venv/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/myproject/venv/lib/python3.8/site-packages/dbbackup/utils.py", line 127, in wrapper
connection.close()
File "/myproject/venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/myproject/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 286, in close
self.validate_thread_sharing()
File "/myproject/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 553, in validate_thread_sharing
raise DatabaseError(
django.db.utils.DatabaseError: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 140423029811616 and this is thread id 140422957233632.
Try adding these lines in setting.py
CELERY_TASK_ALWAYS_EAGER = True

How do you solve a timeout error in a python dropbox upload script?

I'm currently working on a project to do a timelapse with a raspberry pi3 (which works well, capturing the photos ain't a problem).
However, I used another script to upload those photos to a dropbox account and it work all well, until I checked it out today, seeing a timeout error.
Does anyone know how this could solved?
This is the error:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 453, in wrap_socket
cnx.do_handshake()
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1426, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1149, in _raise_ssl_error
raise WantReadError()
OpenSSL.SSL.WantReadError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connection.py", line 344, in connect
ssl_context=context)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/ssl_.py", line 344, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 456, in wrap_socket
raise timeout('select timed out')
socket.timeout: select timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 346, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 306, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='content.dropboxapi.com', port=443): Read timed out. (read timeout=30)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Desktop/time/picture/drop.py", line 16, in <module>
response = db.files_upload(f.read(), dname)
File "/home/pi/.local/lib/python3.5/site-packages/dropbox/base.py", line 2293, in files_upload
f,
File "/home/pi/.local/lib/python3.5/site-packages/dropbox/dropbox.py", line 274, in request
timeout=timeout)
File "/home/pi/.local/lib/python3.5/site-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
timeout=timeout)
File "/home/pi/.local/lib/python3.5/site-packages/dropbox/dropbox.py", line 449, in request_json_string
timeout=timeout,
File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/pi/.local/lib/python3.5/site-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='content.dropboxapi.com', port=443): Read timed out. (read timeout=30)
>>>
This is how the code to upload on dropbox looks:
import dropbox
from time import sleep
db = dropbox.Dropbox('apikeyplaceholder')
for i in range(4500): ##4500
name = 'image{0:04d}.jpg'
fname = '/home/pi/Desktop/time/picture/'+name.format(i)
dname = '/'+name.format(i)
f = open(fname, 'rb')
response = db.files_upload(f.read(), dname)
print ('uploaded:', response)
sleep(585)
f.close()
NEW ERROR:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 317, in _send_until_done
return self.connection.send(data)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1256, in send
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1151, in _raise_ssl_error
raise WantWriteError()
OpenSSL.SSL.WantWriteError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.5/http/client.py", line 1107, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1152, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1103, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 936, in _send_output
self.send(message_body)
File "/usr/lib/python3.5/http/client.py", line 908, in send
self.sock.sendall(data)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 328, in sendall
sent = self._send_until_done(data[total_sent:total_sent + SSL_WRITE_BLOCKSIZE])
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 320, in _send_until_done
raise timeout()
socket.timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.5/http/client.py", line 1107, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1152, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1103, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 936, in _send_output
self.send(message_body)
File "/usr/lib/python3.5/http/client.py", line 908, in send
self.sock.sendall(data)
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 328, in sendall
sent = self._send_until_done(data[total_sent:total_sent + SSL_WRITE_BLOCKSIZE])
File "/home/pi/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 320, in _send_until_done
raise timeout()
urllib3.exceptions.ProtocolError: ('Connection aborted.', timeout())
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Desktop/time/bild/drop.py", line 20, in <module>
response = upload(f, dname)
File "/usr/local/lib/python3.5/dist-packages/backoff/_sync.py", line 94, in retry
ret = target(*args, **kwargs)
File "/home/pi/Desktop/time/bild/drop.py", line 11, in upload
return db.files_upload(f.read(), dname)
File "/home/pi/.local/lib/python3.5/site-packages/dropbox/base.py", line 2293, in files_upload
f,
File "/home/pi/.local/lib/python3.5/site-packages/dropbox/dropbox.py", line 274, in request
timeout=timeout)
File "/home/pi/.local/lib/python3.5/site-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
timeout=timeout)
File "/home/pi/.local/lib/python3.5/site-packages/dropbox/dropbox.py", line 449, in request_json_string
timeout=timeout,
File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/pi/.local/lib/python3.5/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/pi/.local/lib/python3.5/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', timeout())
Before you implement code to handle the timeout you first need to think about how you want to handle it. A common strategy is the following:
Try re-uploading a certain number of times, potentially coupled with exponential backoff (e.g. using this library)
If that fails either skip the current image or abort the process completely.
Depending on your setup, you might want to put the uploading code into a separate thread so that delays during uploads don't interfere with capturing the photos.
A simple example using the backoff library I've linked to above (untested):
from time import sleep
import backoff
import dropbox
import requests
db = dropbox.Dropbox('apikeyplaceholder')
#backoff.on_exception(backoff.expo, requests.exceptions.ReadTimeout)
def upload(f, name):
return db.files_upload(f.read(), dname)
NAME_PATTERN = '/image{0:04d}.jpg'
for i in range(4500):
name = NAME_PATTERN.format(i)
fname = '/home/pi/Desktop/time/picture' + name
with open(fname, 'rb') as f:
response = upload(f, name)
print ('uploaded:', response)
sleep(585)

Strange SSL error when seeding database via command line

I have a file (it's called conversation_template.py) which I use to seed my DynamoDB database, and it worked until very recently.
import boto3
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
table = dynamodb.Table('tablename')
data = {'<data_goes_here>'}
def add_to_table():
table.put_item(Item=data)
add_to_table()
Now, when I run it in my command line, I get this:
Traceback (most recent call last):
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
conn.connect()
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/util/ssl_.py", line 279, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/ssl.py", line 401, in wrap_socket
_context=self, _session=session)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/ssl.py", line 808, in __init__
self.do_handshake()
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:748)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/adapters.py", line 370, in send
timeout=timeout
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 574, in urlopen
raise SSLError(e)
botocore.vendored.requests.packages.urllib3.exceptions.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:748)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "conversation_template.py", line 74, in <module>
add_to_table()
File "conversation_template.py", line 71, in add_to_table
table.put_item(Item=episode)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/client.py", line 312, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/client.py", line 588, in _make_api_call
operation_model, request_dict)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/endpoint.py", line 141, in make_request
return self._send_request(request_dict, operation_model)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/endpoint.py", line 170, in _send_request
success_response, exception):
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/endpoint.py", line 249, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/hooks.py", line 227, in emit
return self._emit(event_name, kwargs)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/hooks.py", line 210, in _emit
response = handler(**kwargs)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/endpoint.py", line 204, in _get_response
proxies=self.proxies, timeout=self.timeout)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/adapters.py", line 431, in send
raise SSLError(e, request=request)
botocore.vendored.requests.exceptions.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:748)
I tried to figure out where the error comes from but I couldn’t do it. Even the error messages didn’t get me anywhere.
I get an SSLError; the protocol is unknown. I found that this type of error could be related to me trying to connect to proxy servers but I am not using one and haven’t done so in the past either.
Any ideas on where this error could come from?
What's worked in the end is to exit my current virtual environment and run:
/Applications/Python\ 3.6/Install\ Certificates.command
And then I entered my virtual environment again and ran:
pip install certifi
That fixed it.
I got help from a friend who suspected it could have to do with the certification verification (related to this: urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error ) but it remains unclear why I didn't get a "Certificate Verification Failed" error.

Categories

Resources