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