in reply to [solved] Long-running DB query makes Tk application unresponsive

Which DBI driver are you using ? (e.g., DBD::ODBC, DBD::mysql, DBD::Pg, etc.)

Which version of Perl/TK are you using ?

Alas, most DBD's have no async i/f, so such things are difficult to handle, esp. given both DBI's and Perl/Tk's less than robust threading implementations.

(Hopefully I'll one day get Thread::Apartment and Perl/TK running together - once I figure out how to handle closures - , and many of these issues will hopefully go away, esp. in combo w/ DBIx::Threaded. The latter may help provide a solution, esp. the async methods (see $sth->start_execute()), tho I haven't yet tried to get pTk and DBIx::Threaded to play nice together - which I'll be needing to do soon as well).

In the near term, you might try running Perl/Tk in its own thread, open a Thread::Queue, and use Storable to transer result data (not the handle, the actual data) to pTk. Then set an after()/repeat() in pTk to poll the queue.

  • Comment on Re: Long-running DB query makes Tk application unresponsive

Replies are listed 'Best First'.
Re^2: Long-running DB query makes Tk application unresponsive
by radiantmatrix (Parson) on Oct 14, 2005 at 06:02 UTC

    I'm not bound to one DBD. The app currently talks to one of two databases, depending on user preference. One is SyBase, and I use DBD::ODBC for that connection. The other is Oracle and I use DBD::Oracle for that.

    In the near future, Oracle will be the only choice, so I'd have no issue planning around DBD::Oracle.

    DBIx::Threaded is a wonderful module! I got it working on my *NIX machines, and I was thrilled -- until I realized that ASPN hasn't managed to compile it into a ppd, yet. Unfortunately, unless the module is available on ASPN, the stupid policy prevents me from using it on Win32.

    I'm figuring out how to implement a Thread::Queue solution as you suggested. I'm somewhat new to threads, so I'm taking my time on this one. Thanks for the suggestions! I'll update this if I end up succeeding on this approach. Any sample code you can provide that might help me get up and running more rapidly would be appreciated, as well.

    <-radiant.matrix->
    A collection of thoughts and links from the minds of geeks
    The Code that can be seen is not the true Code
    "In any sufficiently large group of people, most are idiots" - Kaa's Law