Azure / azure-storage-python

Microsoft Azure Storage Library for Python
https://azure-storage.readthedocs.io
MIT License
339 stars 241 forks source link

Possible multithread unsafe? #559

Closed oak-tree closed 5 years ago

oak-tree commented 5 years ago

Which service(blob, file, queue) does this issue concern?

`from azure.storage.blob import BlockBlobService

blob_service = BlockBlobService(account_name=conf['name'], account_key=conf['key']) `

What problem was encountered?

We are using threadpool to do async uploading to storage. We are creating single BlockBlobService and share it across our threads pool. Is it possible that BlockBlobService is not a thread safe because it creates requests.Session() at StorageClient

EDIT

Is it possible that its threadsafe because we are working against the same storage account? Thanks!

zezha-msft commented 5 years ago

Hi @oak-tree, thanks for reaching out!

To clarify, we make no promise in terms of thread safety, since we could manipulate the session object (like here). Please consider creating a BlockBlobService for each thread.