Problems? Is your data what you think it is? | |
PerlMonks |
simple minded DBI timeoutby Discipulus (Canon) |
on Jan 06, 2018 at 22:16 UTC ( [id://1206839]=perlquestion: print w/replies, xml ) | Need Help?? |
Discipulus has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks and nuns! I've finally build up my Dancer2 web application, where among other tasks I query a mssql db. The query to the db is in a long chain of ajax requests and, unfortunately, it happens sometimes that such damned db slows down all the page because other ajax requests are queued and wait for the DBI connection to fail. Infact it happens that such db is offline or it's so busy to not return data in a decent time. Smashing the dba is not a legal option in this case.. Even if i prefer to have something to show from such db I dont want to wait so long to draw my page that is, thanks to Perl, very responsive in each part, so if db is not fast I'd prefer to skip and going on. This is called timeout. DBI has not a timeout option and unluckily on the unfortunate platform I work on, SIG{ALRM} is known to not work (in DBI docs is explained how to setup a timeout using it). So I worked it around with a preliminar connection check using IO::Socket::INET with a very short timeout:
Anything better? L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Back to
Seekers of Perl Wisdom
|
|