piskvorky/sqlitedict

select_one/select should raise exception immediately

twall opened this issue · 0 comments

twall commented

For those requests which provide a response queue, any raised exception caught by SqliteMultiThread should be posted to the queue instead of logged verbosely.

e.g.

                   try:
                        cursor.execute(req, arg)
                    except Exception as err:
                        if res:
                            res.put(err)
                            continue
                        else:
                            # An exception occurred in our thread, but we may not

With code like this in select:

            res = Queue()  # results of the select will appear as items in this queue
            self.execute(req, arg, res)
            while True:
                rec = res.get()
                if isinstance(rec, Exception):
                    raise rec
                if rec == '--no more--':
                    break
                yield rec