@@ -363,6 +363,24 @@ 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+ int fd = vmp_profile_fileno ();
373+ ret = flush_buffers (fd );
374+ if (ret != 0 ) {
375+ return PyLong_NEW (ret );
376+ }
377+
378+ ret = fsync (fd );
379+ #endif
380+
381+ return PyLong_NEW (ret );
382+ }
383+
366384#ifdef VMPROF_UNIX
367385static PyObject * vmp_get_profile_path (PyObject * module , PyObject * noargs ) {
368386 PyObject * o ;
@@ -437,7 +455,9 @@ static PyMethodDef VMProfMethods[] = {
437455 {"stop_sampling" , stop_sampling , METH_NOARGS ,
438456 "Blocks signals to occur and returns the file descriptor" },
439457 {"start_sampling" , start_sampling , METH_NOARGS ,
440- "Unblocks vmprof signals. After compeltion vmprof will sample again" },
458+ "Unblocks vmprof signals. After completion vmprof will sample again" },
459+ {"flush_buffers" , vmp_flush_buffers , METH_NOARGS ,
460+ "Flushes all pending buffers to the file descriptor" },
441461#ifdef VMP_SUPPORTS_NATIVE_PROFILING
442462 {"resolve_addr" , resolve_addr , METH_VARARGS ,
443463 "Returns the name of the given address" },
0 commit comments