02-20-2018 08:58 PM
Hi all,
I am using LabVIEW 8.5. In there, I call a function to query a database. The read takes 7seconds. The sql function does not have a timeout parameter.
I would like to create my own timeout structure such that after 1second, the program bails and returns an error log instead of hanging for 7 seconds.
Is there a way to do this in LabVIEW 8.5?
02-21-2018 01:17 AM
Hi DT,
I would like to create my own timeout structure such that after 1second, the program bails and returns an error log
This can be achieved with a parallel running structure where you wait for the timeout OR some result of your SQL query.
instead of hanging for 7 seconds.
This cannot be achieved: when the function needs to run for 7s (without a predefined timeout), then you have to wait for this amount of time. THINK DATAFLOW!
Why don't you show some message to the user? Usually this is done by replacing the mouse pointer by a rotating hourglass…
02-21-2018 07:18 AM
What database interface do you use?
I'm pretty sure ADO has a property for setting a command timeout. AFAIK, ADO is used by most LabVIEW toolkits. The property might not be exposed though. You might be able to add it somehow...
02-21-2018 10:56 AM
I'm using sqlite3 database interface, with the lvsqlite wrapper from Martin Vernhout, written in 2006.
I see he's using semaphores to wrap around his database calls, even reads. Removing those in the wrapper doesn't change much. I've also tried using the timeout to have the database read/write timeout after a certain amount of time (500ms) but it doesn't seem to do anything.
02-21-2018 10:59 AM
I would like to create my own timeout structure such that after 1second, the program bails and returns an error log
This can be achieved with a parallel running structure where you wait for the timeout OR some result of your SQL query.
--> I've made a parallel structure, but it is not able to "interrupt" the database query, the query keeps going until its done, which can be much too long for my application. I'd like to be able to just bail.
instead of hanging for 7 seconds.
This cannot be achieved: when the function needs to run for 7s (without a predefined timeout), then you have to wait for this amount of time. THINK DATAFLOW!
--> agreed, but I'd like to break out of whatever function and put some safe values instead. Is this possible?
Why don't you show some message to the user? Usually this is done by replacing the mouse pointer by a rotating hourglass…
02-21-2018 11:46 AM - edited 02-21-2018 11:46 AM
@DT1981 wrote:
I'm using sqlite3 database interface, with the lvsqlite wrapper from Martin Vernhout, written in 2006.
Ah, forgot about SQLite... I'll mention it to Martin next time I see him. Might be a while though... His forum account has not been used since 2013, so a PM might not do anything.
As for a solution, you could dynamically start the read. Then you have full control over the time out. It could be tricky though, the process continues, while the read VI is still running. That could cause problems further down the line, e.g. when you start it again while it is still running.
02-23-2018 03:08 AM
7 secs? What kind of monster question are you performing? Maybe it can be optimized or split into parts or something?
/Y
02-23-2018 04:01 AM
@Yamaeda wrote:
7 secs? What kind of monster question are you performing? Maybe it can be optimized or split into parts or something?
/Y
And if it takes 7 seconds, but you only want to wait 1 second, why not always skip it?
If your getting a lot of results, changes are you only want to \ are able to display a few of them. Adding " TOP n" to the query could be useful...