Dec-14-2018, 01:25 PM
If I'm right, mysql is multi-threads, so you could manage the problem if, at the first step, you start a transaction, and commit (or rollback) after reading what you want. By this way the second step (the same code actually) will start a new transaction when running, wich will wait the end of the first step (the commit) in the appropriate way.
I'm not sure of what's following, but this could be difficult to do if you don't use classes. I allways do it, creating a class for data access, and overriding that class when I need to access data from another part of the script. Establish and keep the connection in the class data ; it will done one time and will stay ready for the successive requests. I allways do it and it works well in that cases of the GUI event loop cross itself, making situations when you don't know exactly what occurs because it's almost difficult to debug.
Also, check what happens if mysql do a transaction for each request if you don't start it explicitely and commit it when you want.
I don't know if it's helpfull in your case, but I'm pretty sure if you make the effort to create separated classes for the different parts of your code, you will get a good value.
I'm not sure of what's following, but this could be difficult to do if you don't use classes. I allways do it, creating a class for data access, and overriding that class when I need to access data from another part of the script. Establish and keep the connection in the class data ; it will done one time and will stay ready for the successive requests. I allways do it and it works well in that cases of the GUI event loop cross itself, making situations when you don't know exactly what occurs because it's almost difficult to debug.
Also, check what happens if mysql do a transaction for each request if you don't start it explicitely and commit it when you want.
I don't know if it's helpfull in your case, but I'm pretty sure if you make the effort to create separated classes for the different parts of your code, you will get a good value.