What is purpose async query_lock in core.py?

If I understand correctly, the database provides some level of the locking mechanism. So what exactly are we trying to synchronize?

For reference, I’m using Postgres database.

If anything otherwise, Please help me understand the reason for the lock.

Thank You

In case of PostgreSQL you cannot send next query to database using same connection until you’ve read result from previous query. I believe it’s same for other database engines.

Here’s relevant documentation: https://www.postgresql.org/docs/10/libpq-async.html

After successfully calling PQsendQuery , call PQgetResult one or more times to obtain the results. PQsendQuery cannot be called again (on the same connection) until PQgetResult has returned a null pointer, indicating that the command is done.