awslabs / amazon-transcribe-streaming-sdk

The Amazon Transcribe Streaming SDK is an async Python SDK for converting audio into text via Amazon Transcribe.
Apache License 2.0
151 stars 38 forks source link

TranscribeStreamingClient creates a new AWSCRTEventLoop and associated thread each time it is instanced #78

Closed gscalise closed 2 years ago

gscalise commented 2 years ago

https://github.com/awslabs/amazon-transcribe-streaming-sdk/blob/95349afd317b83b06b0c3dadc3a51720595bf876/amazon_transcribe/client.py#L63

In turn, AWSCRTEventLoop creates a new EventLoopGroup with one new thread each time it is instanced.

https://github.com/awslabs/amazon-transcribe-streaming-sdk/blob/95349afd317b83b06b0c3dadc3a51720595bf876/amazon_transcribe/__init__.py#L20-L30

When not reusing instances of TranscribeStreamingClient (to avoid issues #76 and #77) this causes multiple event loop threads (that can't be stopped until the process shuts down) to be created, potentially leading to thread exhaustion and/or unnecessarily high number of threads essentially blocked in epoll_wait on different epoll file descriptors.

nateprewitt commented 2 years ago

Resolved with #81.