Python 3.3 has os.sync, see the docs. The source confirms it is the same thing.
For Python 2 you can to make an external call to the system:
from subprocess import check_callcheck_call(['sync'])
As said, Python 3.3 has the call - on Python 2.x, since it is a simplesystem call, requiring no data to be passed back and forth, you can use ctypes to make the call:
>>> import ctypes>>> libc = ctypes.CDLL("libc.so.6")>>> libc.sync()0
Combining the two answers, I use the following at the top of my module:
if hasattr(os, 'sync'): sync = os.syncelse: import ctypes libc = ctypes.CDLL("libc.so.6") def sync(): libc.sync()