-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpyWrapperTest.cpp
43 lines (33 loc) · 1.04 KB
/
pyWrapperTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "pyWrapper.h"
void thread_func(int iteration, PyWrapper *w) {
for (int i = 0; i < 1; i++) {
w->wrapperError(i);
// w.wrapperTest()
std::map <std::string, std::string> c;
c.insert({"key", "cc"});
w->wrapperInit(c);
w->wrapperTest();
std::stringstream msg;
msg << "iteration: " << iteration << " thread: " << std::this_thread::get_id() << " w.get_x(): " << std::endl;
std::cout << msg.str();
// std::this_thread::sleep_for(100ms);
}
}
void ini() {
std::cout << "ccccccccdddddddd" << std::endl;
// py::scoped_interpreter python;
}
int main() {
// Manager *manager = new Manager();
py::initialize_interpreter();
py::gil_scoped_release release; // add this to release the GIL
std::vector <std::thread> threads;
PyWrapper *w = new PyWrapper();
for (int i = 0; i < 5; i++)
threads.push_back(std::thread(thread_func, 1, w));
for (auto &t: threads) {
t.join();
}
std::cout << "olddd";
return 0;
}