sys.setcheckinterval() never gets updated second time. Bug?

K

k3xji

Hi all,

Yesterday I opened a thread for this issue where I was calling
sys.setcheckinterval() with sys.maxint and then try to set it to a
lower value but did not succeed with that. Here it is:
http://groups.google.com/group/comp...6470245a704/f80733445ce30a36#f80733445ce30a36

I think we might have a bug or a undocumented intention.

Here is the related code in Python/ceval.c, line number 833 Python
2.6.2 source code:

if (--_Py_Ticker < 0) {
if (*next_instr == SETUP_FINALLY) {
/* Make the last opcode before
a try: finally: block uninterruptable. */
goto fast_next_opcode;
}
_Py_Ticker = _Py_CheckInterval;
tstate->tick_counter++;

From what I understand is this, when you call sys.setcheckinterval()
with some value, _Py_Ticker volatile variable is not updated until
next context-switch. As in our example we set _Py_CheckInterval to
sys.maxint() then the thread starts ticking and even we set
checkinterval to a lower value, it is never updated as it waits for
the next context switch. Of course, if you do a blocking call, context
switch occurs and you think everything is fine, but as _Py_Ticker gets
never to "0" every thread starts running till finding a blocking call
which, in turn results in uncontrolled thread scheduling behavior.

As far as I understand, setcheckinterval() never designed to handle
such big values like sys.maxint to simulate unpreemtable behavior. If
the case is so, I think in any way we should document it somewhere.

Comments?

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top