MCPcopy Create free account
hub / github.com/TuGraph-family/tugraph-db / PythonPluginManagerImpl

Method PythonPluginManagerImpl

src/plugin/python_plugin.cpp:43–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41namespace lgraph {
42#if LGRAPH_ENABLE_PYTHON_PLUGIN
43PythonPluginManagerImpl::PythonPluginManagerImpl(LightningGraph* db, const std::string& graph_name,
44 const std::string& dir, int max_idle_seconds,
45 int max_plugin_lifetime_seconds)
46 : graph_name_(graph_name),
47 plugin_dir_(dir),
48 max_idle_seconds_(max_idle_seconds <= 0 ? std::numeric_limits<int>::max()
49 : max_idle_seconds),
50 max_plugin_lifetime_seconds_(max_plugin_lifetime_seconds) {
51 fma_common::FilePath p(db->GetConfig().dir);
52 db_dir_ = p.Dir();
53 auto& scheduler = fma_common::TimedTaskScheduler::GetInstance();
54 _kill_task = scheduler.ScheduleReccurringTask(
55 max_idle_seconds * 1000, [this](fma_common::TimedTask*) {
56 std::lock_guard<std::mutex> l(_mtx);
57 CleanUpIdleProcessesNoLock();
58 auto it = _marked_processes.begin();
59 while (it != _marked_processes.end()) {
60 if ((*it)->IsAlive()) {
61 (*it)->Kill();
62 it++;
63 } else {
64 it = _marked_processes.erase(it);
65 }
66 }
67 });
68}
69
70PythonPluginManagerImpl::~PythonPluginManagerImpl() {
71 _kill_task->Cancel();

Callers

nothing calls this directly

Calls 7

DirMethod · 0.80
IsAliveMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
KillMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected