Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I capture this warning message when the query is blocking?

Tags:

python

sap-ase

When I do a query with isql I get the following message and the query blocks.

The transaction log in database foo is almost full. Your transaction is being suspended until space is made available in the log.

When I do the same from Python:

cursor.execute(sql)

The query blocks, but I would like see this message.

I tried:

Sybase.set_debug(sys.stderr)
connection.debug = 1

I'm using:

  • python-sybase-0.40pre1
  • Adaptive Server Enterprise/15.5/EBF 18164

EDIT: The question is, "How do I capture this warning message in the python program?"

like image 766
Eddy Pronk Avatar asked Nov 26 '22 16:11

Eddy Pronk


1 Answers

Good question and I'm not sure I can completely answer it. Here are some ideas.

Sybase.py uses logging. Make sure you are using it. To "bump" the logging out I would do this:

import logging
logging.basicConfig(level = logging.INFO,
                    format = "%(asctime)s %(levelname)s [%(filename)s] (%(name)s) %(message)s",
                    datefmt = "%H:%M:%S", stream = sys.stdout)
log = logging.getLogger('sybase')
log.setLevel(logging.DEBUG)

And apparently (why is beyond me??) to get this working in Sybase.py you need to set a global DEBUG=True (see line 38)

But then if we look at def execute we can see (as you point out) that it's blocking. We'll that sort of answers your question. You aren't going to get anything back as it's blocking it. So how do you fix this - write a non-blocking excute method;) There is some hints in examples/timeout.py. Apparently someone else has run up on this but hasn't really fixed it.

I know this didn't probably help but I spent 15 minutes looking - I should at least tell you what I found.. You would think that execute would give you some result -- Wait what is the value of result in line 707??

                while 1:
                    status, result = self._cmd.ct_results()
                    if status != CS_SUCCEED:
                        break

If status != CS_SUCCEED (which I'm assuming in your case is True) can you simply see what "result" is equal to? I wonder if they just failed raise the result as an exception?

like image 169
rh0dium Avatar answered Nov 29 '22 07:11

rh0dium