Commits

Mikhail Korobov committed 87c5215

yappi.is_running() function

Comments (0)

Files changed (2)

     return Py_None;
 }
 
+static PyObject *
+is_running(void)
+{
+    return Py_BuildValue("i", yapprunning);
+}
+
 static PyMethodDef yappi_methods[] = {
     {"start", start, METH_VARARGS, NULL},
     {"stop", stop, METH_VARARGS, NULL},
     {"get_stats", get_stats, METH_VARARGS, NULL},
     {"enum_stats", enum_stats, METH_VARARGS, NULL},
     {"clear_stats", clear_stats, METH_VARARGS, NULL},
+    {"is_running", is_running, METH_VARARGS, NULL},
     {"profile_event", profile_event, METH_VARARGS, NULL}, // for internal usage. do not call this.
     {NULL, NULL}      /* sentinel */
 };
 import threading
 import _yappi
 
-__all__ = ['start', 'stop', 'enum_stats', 'print_stats', 'clear_stats']
+__all__ = ['start', 'stop', 'enum_stats', 'print_stats', 'clear_stats', 'is_running']
 
 SORTTYPE_NAME = _yappi.SORTTYPE_NAME
 SORTTYPE_NCALL = _yappi.SORTTYPE_NCALL
 def clear_stats():
     _yappi.clear_stats()
 
+def is_running():
+    return bool(_yappi.is_running())
+
 def main():
     import os, sys
     from optparse import OptionParser