Skip to content

Error when creating whl with std::thread code #35

Description

@paulgheorghecristian

Helo,

When I try creating threads in CPP, creating a wheel and importing in pyodide 0.21.0, I get this:

index.js:1 CppException std::__2::system_error: thread constructor failed: Resource temporarily unavailable

This is the program:

void run_threads() {
	std::thread t([&](){
		for (int i = 0; i < 10; i++) {
			std::cout << "i:" << i << std::endl;
		}
	});
	std::thread t2([&](){
		for (int j = 10; j < 20; j++) {
			std::cout << "j:" << j << std::endl;
		}		
	});

	t.join();
	t2.join();
}

PYBIND11_MODULE(example, m){
  m.def("run_threads", &run_threads, "Run threads");
}

I know there are some issues with running multithreaded code, is there any way I can make this work?

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions