exchangelib not work with some subject filters

333 views Asked by At

I am having the following problem to get the unread emails. When the subject is "REALIZADAS" it works fine and brings me the emails quickly, but when the subject is "G.09.xlsx" it takes a long time and fails to deliver this error

'An existing connection was forced to break by the remote host', None, 10054, None) ", ConnectionResetError (10054, 'An existing connection was forced to break by the remote host'

This is the untranslated error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Rocketbot\Desktop\Rocketbot\\modules\libs\exchangelib\services.py", line 89, in _get_elements
    response = self._get_response_xml(payload=payload)
  File "C:\Users\Rocketbot\Desktop\Rocketbot\\modules\libs\exchangelib\services.py", line 162, in _get_response_xml
    stream=self.streaming,
  File "C:\Users\Rocketbot\Desktop\Rocketbot\\modules\libs\exchangelib\util.py", line 677, in post_ratelimited
    _raise_response_errors(r, protocol, log_msg, log_vals)  # Always raises an exception
  File "C:\Users\Rocketbot\Desktop\Rocketbot\\modules\libs\exchangelib\util.py", line 749, in _raise_response_errors
    raise response.headers['TimeoutException']
  File "C:\Users\Rocketbot\Desktop\Rocketbot\\modules\libs\exchangelib\util.py", line 631, in post_ratelimited
    stream=stream)
  File "site-packages\requests\sessions.py", line 578, in post
  File "site-packages\requests\sessions.py", line 530, in request
  File "site-packages\requests\sessions.py", line 683, in send
  File "site-packages\requests\models.py", line 829, in content
  File "site-packages\requests\models.py", line 754, in generate
requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(10054, 'Se ha forzado la interrupción de una conexión existente por el host remoto', None, 10054, None)", ConnectionResetError(10054, 'Se ha forzado la interrupción de una conexión existente por el host remoto', None, 10054, None))

This is the code

id_ = []
mails_filters = a.inbox.filter(subject=filter_)
for m in mails_filters:
    if not m.is_read:
        id_.append(m.id)

I tried with

.filter (subject__contains = filter_)
.filter (Q ("subject:" + filter_))

and it only worked for me when the filter was .filter (subject__contains = "09"), if I use "G" or "xlsx" it doesn't work. I do not know what it could be. Maybe it's the time it takes to search? Can I modify that time so that it waits longer without getting the error?

0

There are 0 answers