@@ -363,6 +363,24 @@ start_sampling(PyObject *module, PyObject *noargs)
363
363
Py_RETURN_NONE ;
364
364
}
365
365
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
+
366
384
#ifdef VMPROF_UNIX
367
385
static PyObject * vmp_get_profile_path (PyObject * module , PyObject * noargs ) {
368
386
PyObject * o ;
@@ -437,7 +455,9 @@ static PyMethodDef VMProfMethods[] = {
437
455
{"stop_sampling" , stop_sampling , METH_NOARGS ,
438
456
"Blocks signals to occur and returns the file descriptor" },
439
457
{"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" },
441
461
#ifdef VMP_SUPPORTS_NATIVE_PROFILING
442
462
{"resolve_addr" , resolve_addr , METH_VARARGS ,
443
463
"Returns the name of the given address" },
0 commit comments