@@ -363,6 +363,21 @@ 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 fd , ret ;
370+
371+ fd = vmp_profile_fileno ();
372+ ret = flush_buffers (fd );
373+ if (ret != 0 ) {
374+ return PyLong_NEW (ret );
375+ }
376+
377+ ret = fsync (fd );
378+ return PyLong_NEW (ret );
379+ }
380+
366381#ifdef VMPROF_UNIX
367382static PyObject * vmp_get_profile_path (PyObject * module , PyObject * noargs ) {
368383 PyObject * o ;
@@ -437,7 +452,9 @@ static PyMethodDef VMProfMethods[] = {
437452 {"stop_sampling" , stop_sampling , METH_NOARGS ,
438453 "Blocks signals to occur and returns the file descriptor" },
439454 {"start_sampling" , start_sampling , METH_NOARGS ,
440- "Unblocks vmprof signals. After compeltion vmprof will sample again" },
455+ "Unblocks vmprof signals. After completion vmprof will sample again" },
456+ {"flush_buffers" , vmp_flush_buffers , METH_NOARGS ,
457+ "Flushes all pending buffers to the file descriptor" },
441458#ifdef VMP_SUPPORTS_NATIVE_PROFILING
442459 {"resolve_addr" , resolve_addr , METH_VARARGS ,
443460 "Returns the name of the given address" },
0 commit comments