C++ 为什么MonitoringManager::OnRequestSuccessed()中的断言(s_监视器)失败?

C++ 为什么MonitoringManager::OnRequestSuccessed()中的断言(s_监视器)失败?,c++,amazon-s3,assertion,aws-sdk-cpp,C++,Amazon S3,Assertion,Aws Sdk Cpp,我上传一个文件到S3。收到请求后,我立即收到监控经理的异常,我不知道自己做错了什么。我们在应用程序中使用多个线程 异常:断言失败。节目:。。。监视器…ger.cpp第55行 Expresion:s_监视器 cpp文件:第55行 方法“uploadFileToS3”: bool result = false; const Aws::SDKOptions options; Aws::InitAPI(options); { std::shared_ptr<Aws::Utils::Th

我上传一个文件到S3。收到请求后,我立即收到监控经理的异常,我不知道自己做错了什么。我们在应用程序中使用多个线程

异常:断言失败。节目:。。。监视器…ger.cpp第55行 Expresion:s_监视器

cpp文件:第55行


方法“uploadFileToS3”:

bool result = false;

const Aws::SDKOptions options;
Aws::InitAPI(options);
{
    std::shared_ptr<Aws::Utils::Threading::Executor> m_executor = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("TransferTests", 4);
    Aws::Transfer::TransferManagerConfiguration config(m_executor.get());
    config.s3Client = client;
    auto transmanager = Aws::Transfer::TransferManager::Create(config);

    std::shared_ptr<Aws::Transfer::TransferHandle> handle = transmanager->UploadFile(fileDestination, Aws::String(S3_BUCKET_NAME),
        Aws::String(s3key), Aws::String("multipart/form-data"), metadata);

    handle->WaitUntilFinished();

    result = isAwsActionSuccessful(handle) && boost::filesystem::remove(fileDestination);

}
Aws::ShutdownAPI(options);
return result;
bool结果=false;
常数Aws::SDK选项选项;
Aws::InitAPI(选项);
{
std::shared_ptr m_executor=Aws::MakeShared(“TransferTests”,4);
Aws::Transfer::TransferManagerConfiguration配置(m_executor.get());
config.s3Client=客户端;
自动transmanager=Aws::Transfer::TransferManager::Create(配置);
std::shared_ptr handle=transmanager->UploadFile(文件目的地,Aws::String(S3_BUCKET_名称),
Aws::String(s3key)、Aws::String(“多部分/表单数据”)、元数据;
句柄->WaitUntilFinished();
结果=isawActionSuccessful(句柄)&&boost::filesystem::remove(fileDestination);
}
Aws::关闭API(选项);
返回结果;

问题在于我的应用程序使用了多个线程,因此API被初始化并多次关闭。当我在应用程序中只执行了一次初始化/关闭API时,问题就解决了。

删除Aws::ShutdownAPI(选项)似乎暂时解决了我的问题。我猜线程多次调用该方法导致断言失败,但这只是猜测
bool result = false;

const Aws::SDKOptions options;
Aws::InitAPI(options);
{
    std::shared_ptr<Aws::Utils::Threading::Executor> m_executor = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("TransferTests", 4);
    Aws::Transfer::TransferManagerConfiguration config(m_executor.get());
    config.s3Client = client;
    auto transmanager = Aws::Transfer::TransferManager::Create(config);

    std::shared_ptr<Aws::Transfer::TransferHandle> handle = transmanager->UploadFile(fileDestination, Aws::String(S3_BUCKET_NAME),
        Aws::String(s3key), Aws::String("multipart/form-data"), metadata);

    handle->WaitUntilFinished();

    result = isAwsActionSuccessful(handle) && boost::filesystem::remove(fileDestination);

}
Aws::ShutdownAPI(options);
return result;