[wxpython-users] Abort connecting to a database (threading)

Mark Guagenti mgenti at gentiweb.com
Mon Sep 8 06:27:38 PDT 2008


Some DB library's may have a way that you can use them in an
asynchronous mode.  We were using psycopg2 in a project and it had an
async mode that you could use and poll for the result of the
operation.
--Mark

On Sat, Sep 6, 2008 at 11:29 PM, Alastair Medford
<alastairmedford at gmail.com> wrote:
> Currently I'm trying to write code that will let me connect to a
> database while have an option to cancel, since if the program cannot
> connect to the database it takes a long time to timeout. I believe
> threads are the best way to do this, but I'm a bit confused about how
> to cause an abort. From the examples I've looked at,
> (http://wiki.wxpython.org/index.cgi/LongRunningTasks ), it seems like
> I have to make the second thread poll to see if an abort has occurred,
> and then react from there. The problem is connecting to a database
> doesn't involve a loop or anything, it's just running a single
> function. Since this is the case, is there any other way to check for
> an abort other than polling? Or is this just not possible? If it has
> to be done via polling, the only way I can think of doing this would
> be to edit the database library to check for an abort while it's
> checking for a response from the database, which would be way beyond
> my ability.
>
> Thanks,
> --
> Alastair Medford
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>


More information about the wxpython-users mailing list