avoid lock and allow two scripts to insert data in one table
idle in transaction means it is waiting for data from the client, not that is waiting on a lock.  

And your excerpt from pg_lock supports this, assuming the last column is the "granted" column.  All locks have been granted, no one is blocking.

If your scripts are blocking each other, it seems to be happening outside of the database.  Or at least, outside of that particular database.