Skip to content

Memory leak in long-running scripts when using OAuth #1100

@sunilpurwar

Description

@sunilpurwar

Describe the bug
connecting to the EWS with python using Exchanhelib 4.7.4 to implement OAuth on Office 365 memory usage going up with every request.

To Reproduce

from exchangelib import OAuth2Credentials,Build,Version,Configuration, OAUTH2,Account,IMPERSONATION
## Removing below info client _id client_secret, tenant_id because it is confidential 
CLIENT_ID = '*****************'
CLIENT_SECRET = '***********'
TENANT_ID = '****'
version = Version(build=Build(15, 0, 12, 34))

credentials = OAuth2Credentials(
  client_id=CLIENT_ID, client_secret=CLIENT_SECRET, tenant_id=TENANT_ID 
)

config = Configuration(service_endpoint = 'https://outlook.office365.com/EWS/Exchange.asmx',
                       credentials=credentials,
                       auth_type=OAUTH2 ,#NTLM, ##'OAuth 2.0', NTLM,OAUTH2
                       version=version) 
                        

account = Account(
    primary_smtp_address='[email protected]',  ## need to put valid adress 
    credentials=credentials, 
    autodiscover=False,
    config=config,
    access_type=IMPERSONATION
)

mails = list(account.inbox.filter(is_read=False).only(
        'is_read', 'subject', 'body','text_body','datetime_received',
        'sender','to_recipients','cc_recipients','bcc_recipients',
        'attachments','importance'
    ).order_by('datetime_received')[:1])

Additional context
Python - 3.8.5
Exchangelib - 4.7.4
memory

Note : hitting EWS server every minute to get the mails , earlier we are using Exchangelib Basic authentication which is working fine but now deprecating , so we just try to move on OAuth on Office 365 using exchnagelib 4.7.4 causing this issue memory usage going up with every request on our every env Dev/QA and UAT,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions