used flock

(cherry picked from commit e67c66e5036ea1974760036701a0ee801e63875c)
fixed coding style in module ``flock``

(cherry picked from commit a3b2dcadd39477aa2ab83a19ef81d8284cd1681c)