I'm using asynchronous workflow with synchronous code within it. How do I check, if synchronous functions are blocking or not, to be sure that nothing breaks during execution.
async def download_upload_xmls_async(message,count,id,conn1,cursor1,conn2,cursor2):
# SOME CODE
xml = await req(urlX, headers)
print('Got message')
write(message_count, id, conn1, cursor1)
print('Wrote progress')
send_message("Send" + xml, id, conn2, cursor2)
print('Sent message')
write_locally(data)
await message.ack()
In code above, how do I check, that functions write and send_message are non-blocking? They work with db, that i cannot access to check if everything works as expected. Also can I assume, that if function write_locally works correctly, that my previous functions also worked correctly?
Functions write and send_message do almost same thing - they take data and execute query on PostgreSQL db using connection and cursor passed to them. Function write_locally makes writes to csv file.
def send_message(message, id, con, cur, **nargs):
params = {
#some params
}
union_params= {**params, **nargs}
data = json.dumps(union_params, ensure_ascii=False)
cur.execute(
#Query
)
con.commit()
Also i have to add, that connection and cursor were created with aiopg, so all their methods are coroutines.