LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timeout structure for a function

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?

0 Kudos
Message 1 of 8
(3,918 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(3,891 Views)

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...

0 Kudos
Message 3 of 8
(3,868 Views)

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.

0 Kudos
Message 4 of 8
(3,845 Views)

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…

0 Kudos
Message 5 of 8
(3,842 Views)

@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.

0 Kudos
Message 6 of 8
(3,827 Views)

7 secs? What kind of monster question are you performing? Maybe it can be optimized or split into parts or something?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 8
(3,777 Views)

@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...

0 Kudos
Message 8 of 8
(3,773 Views)