The second evolution consists of making the S3 upload operation run in a dedicated thread. This upload operation is based on a blocking API, so it should be executed in a dedicated thread to avoid blocking the event loop. In RxPY there is no scheduler to execute some operators on a dedicated thread. However, this is not really needed because the same result is possible by creating a thread pool containing only one thread. So another scheduler is created for the S3 upload operations, as detailed in the following example:
s3_scheduler = ThreadPoolScheduler(max_workers=1)
For this scheduling, the observe_on operator can be used directly to move the execution context from the encoder thread pool to ...