How to access the file shared between different accessors?
Your best bet might be to ditch the use of a file and use sockets.  The Java program generates and caches the output until a Python script is listening.  The Python script then accepts the data, and handles it.
Alternatively, you could use IPC signalling between the two processes, although this seems a lot more messy than sockets, IMHO.
Otherwise, a .lock file seems like your best bet.
I have code written on Java which writes all data to the file and then I have python script which handles this data.
They run completely separately and python script can be run by schedule but it also removing handled records from the file.
The question is in implementation for the access to the file when java code from first process will try to write something and python code from second process will try to remove handled record?
First thought was to have .lock file physically created when one of the processes updating the file but perhaps there are some other solutions to consider?
Thank you.