Skip to content

Threads created and not destroyed with each client #239

@dgmp88

Description

@dgmp88

Each time you search on a client, new threads are created that are not destroyed. e.g. if you need to use many clients and run

def test():
    auth_string = """****"""
    client = google_ads.client.GoogleAdsClient.load_from_string(auth_string)
    service = client.get_service("GoogleAdsService")
    res = service.search(
        "****", "select campaign.resource_name from campaign limit 1"
    )
    res = list(res)


for i in range(10000):
    test()

Then run watch -n1 "ps -eLf | wc -l" in another terminal, you can see the number of threads creeping up. After a while you'll reach your machines thread limit then have lots of system wide problems.

If you comment out the last line turning the results generator into a list, the problem disappears, so I think the thread creation is occurring there?

As far as I can tell there isn't a .close() function on the client or service I'm missing?

Metadata

Metadata

Assignees

Labels

P1Breaking issue affecting some users or workflowsbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions