[Python-Dev] Investigated ref leak report related to thread (regrtest.py -R ::)

2007-06-18 Thread ocean
Hello. I investigated ref leak report related to thread.
Please run python regrtest.py -R :: test_leak.py (attached file)
Sometimes ref leak is reported.
# I saw this as regression failure on python-checkins.

# total ref count 92578 -> 92669
  _Condition 2
  Thread 6
  _Event 1
  bool 10
  instancemethod 1
  code 2
  dict 9
  file 1
  frame 3
  function 2
  int 1
  list 2
  builtin_function_or_method 5
  NoneType 2
  str 27
  thread.lock 7
  tuple 5
  type 5

Probably this happens because threading.Thread is implemented as Python
code,
(expecially threading.Thread#join), the code of regrtest.py

if i >= nwarmup:
deltas.append(sys.gettotalrefcount() - rc - 2)

can run before thread really quits. (before Moudles/threadmodule.c
t_bootstrap()'s

 Py_DECREF(boot->func);
 Py_DECREF(boot->args);
 Py_XDECREF(boot->keyw);

runs)

So I experimentally inserted the code to wait for thread termination.
(attached file experimental.patch) And I confirmed error was gone.

# Sorry for hackish patch which only runs on windows. It should run
# on other platforms if you replace Sleep() in Python/sysmodule.c
# sys_debug_ref_leak_leave() with appropriate function.



import threading
import time
import unittest
from test import test_support

class Thread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self._stop = False
self.ready = threading.Event()

def stop(self):
self._stop = True
self.join()

def run(self):
self.ready.set()
while not self._stop:
time.sleep(0.5)

class LeakTests(unittest.TestCase):
def test_leak(self):
def foo():
raise RuntimeError("foo")
self.assertRaises(RuntimeError, foo)

def setUp(self):
self._thread = Thread()
self._thread.start()
self._thread.ready.wait()

def tearDown(self):
self._thread.stop()

def test_main():
test_support.run_unittest(LeakTests)

if __name__ == "__main__":
test_main()



experimental.patch
Description: Binary data
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Investigated ref leak report related to thread (regrtest.py -R ::)

2007-06-18 Thread Aahz
On Mon, Jun 18, 2007, ocean wrote:
>
> Hello. I investigated ref leak report related to thread.
> Please run python regrtest.py -R :: test_leak.py (attached file)
> Sometimes ref leak is reported.

Please post a bug report to SF and report the bug number here.  When you
post bugs only to the list they get lost.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Investigated ref leak report related to thread (regrtest.py -R ::)

2007-06-18 Thread ocean
> Please post a bug report to SF and report the bug number here.  When you
> post bugs only to the list they get lost.
> -- 
> Aahz ([EMAIL PROTECTED])   <*>
http://www.pythoncraft.com/
>
> "as long as we like the same operating system, things are cool." --piranha

Thank you for pointing it out. Done. http://www.python.org/sf/1739118

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Python 3000 Status Update (Long!)

2007-06-18 Thread Guido van Rossum
I've written up a comprehensive status report on Python 3000. Please read:

http://www.artima.com/weblogs/viewpost.jsp?thread=208549

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com