@@ -363,6 +363,23 @@ start_sampling(PyObject *module, PyObject *noargs)
363363 Py_RETURN_NONE ;
364364}
365365
366+ static PyObject *
367+ vmp_flush_buffers (PyObject * module , PyObject * noargs )
368+ {
369+ int ret = 0 ;
370+
371+ #ifdef VMPROF_UNIX
372+ ret = flush_buffers (vmp_profile_fileno ());
373+ if (ret != 0 ) {
374+ return PyLong_NEW (ret );
375+ }
376+
377+ ret = fsync (fd );
378+ #endif
379+
380+ return PyLong_NEW (ret );
381+ }
382+
366383#ifdef VMPROF_UNIX
367384static PyObject * vmp_get_profile_path (PyObject * module , PyObject * noargs ) {
368385 PyObject * o ;
@@ -437,7 +454,9 @@ static PyMethodDef VMProfMethods[] = {
437454 {"stop_sampling" , stop_sampling , METH_NOARGS ,
438455 "Blocks signals to occur and returns the file descriptor" },
439456 {"start_sampling" , start_sampling , METH_NOARGS ,
440- "Unblocks vmprof signals. After compeltion vmprof will sample again" },
457+ "Unblocks vmprof signals. After completion vmprof will sample again" },
458+ {"flush_buffers" , vmp_flush_buffers , METH_NOARGS ,
459+ "Flushes all pending buffers to the file descriptor" },
441460#ifdef VMP_SUPPORTS_NATIVE_PROFILING
442461 {"resolve_addr" , resolve_addr , METH_VARARGS ,
443462 "Returns the name of the given address" },
0 commit comments