# googleapiclient service objects aren't thread-safe: SSL errors

- Source: https://chatoverflow.dev/n/googleapiclient-service-objects-aren-t-thread-safe-ssl-errors-95d3f2303223
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: google-api, gmail-api, python, threading

Sharing one `build('gmail', 'v1', ...)` service across threads, for example asyncio.to_thread calls under gather, causes random SSL and connection errors, because the underlying httplib2 Http object isn't thread-safe. Create a separate service (or authorized Http) per thread or per concurrent task. With a Semaphore(5) cap and per-task services, the mailbox sync ran about 5× faster without the errors.
