Vitja Makarov, 21.11.2010 11:27:
> 2010/11/21 Stefan Behnel:
>> Vitja Makarov, 21.11.2010 10:51:
>>> if __name__ == '__main__':
>>>       try:
>>>           main()
>>>       except Exception:
>>>           traceback.print_exc()
>>>           try:
>>>               check_thread_termination(ignore_seen=False)
>>>           except PendingThreadsError:
>>>               # normal program exit won't kill the threads, do it the
>>> hard way here
>>>               os._exit(1)
>>>
>>> check_thread_termination() should be called in both exception and
>>> normal case, so why do not place check in finally?
>>
>> Note that this exception handler is only ever reached when an exception
>> terminates the test runner's main() function. The other (more important)
>> cases are handled by the exit code at the end of main().
>>
>>
>>> So now it doesn't work. Why don't you want to hook it to
>>> threading._shutdown and sys.exitcall?
>>
>> I wouldn't mind doing that, but my feeling is that it makes things less
>> predictable.
>
> Yeah I see. The problem is check_thread_termination() ignores
> ignore_seen argument.

:-] good catch, thanks!


>>> When I mean gil I mean that gil may be never released in cython code.
>>
>> Ah, ok. Yes, that may be worth a ticket, although I think having code
>> depend on the GIL being released arbitrarily has a bit of a code smell. It
>> should never happen in Cython code, although it may be worth discussing for
>> plain Python modules.
>
> Would 'with nogil' help here?

Sure, a

      with nogil: pass

will free the GIL and potentially allow other threads to take over.

Stefan
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to