Coder Social home page Coder Social logo

Comments (3)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 19, 2024
attaching file

Original comment by [email protected] on 17 Oct 2013 at 11:19

Attachments:

from pypyodbc.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 19, 2024
即使直接改用del掉也不可以
---------------------

import pypyodbc, os, gc


def test():
    # if comment the __del__ method in connection and cursor objects, this problem will be solved
    mdb_file = "test.mdb"
    db = pypyodbc.win_create_mdb(mdb_file) if not os.path.isfile(mdb_file) else mdb_file

    #try:
    #    with pypyodbc.win_connect_mdb(mdb_file) as db_con:
    #        cur = db_con.cursor()
    #except pypyodbc.Error, i:
    #    print i.__str__().decode("unicode-escape")
    con = pypyodbc.win_connect_mdb(mdb_file)
    cur = con.cursor()

    del con,cur
print "pypyodbc version %s" % pypyodbc.version
count = 5
while count:
    test()
    print "# --- %d" % count
    print "collected", gc.collect()
    print "garbage count", gc.garbage.__len__()
    print "garbage", gc.garbage
    print "# ---\n"
    count -= 1

----------------
----------------
pypyodbc version 1.2.0
# --- 5
collected 97
garbage count 2
garbage [<pypyodbc.Cursor instance at 0x025FB3C8>, <pypyodbc.Connection 
instance at 0x025F74E0>]
# ---

# --- 4
collected 149
garbage count 4
garbage [<pypyodbc.Cursor instance at 0x025FB3C8>, <pypyodbc.Connection 
instance at 0x025F74E0>, <pypyodbc.Connection instance at 0x025C5B70>, 
<pypyodbc.Cursor instance at 0x0248DF30>]
# ---

# --- 3
collected 149
garbage count 6
garbage [<pypyodbc.Cursor instance at 0x025FB3C8>, <pypyodbc.Connection 
instance at 0x025F74E0>, <pypyodbc.Connection instance at 0x025C5B70>, 
<pypyodbc.Cursor instance at 0x0248DF30>, <pypyodbc.Connection instance at 
0x025C5A30>, <pypyodbc.Cursor instance at 0x025F7850>]
# ---

# --- 2
collected 149
garbage count 8
garbage [<pypyodbc.Cursor instance at 0x025FB3C8>, <pypyodbc.Connection 
instance at 0x025F74E0>, <pypyodbc.Connection instance at 0x025C5B70>, 
<pypyodbc.Cursor instance at 0x0248DF30>, <pypyodbc.Connection instance at 
0x025C5A30>, <pypyodbc.Cursor instance at 0x025F7850>, <pypyodbc.Connection 
instance at 0x025CEC38>, <pypyodbc.Cursor instance at 0x025F76E8>]
# ---

# --- 1
collected 149
garbage count 10
garbage [<pypyodbc.Cursor instance at 0x025FB3C8>, <pypyodbc.Connection 
instance at 0x025F74E0>, <pypyodbc.Connection instance at 0x025C5B70>, 
<pypyodbc.Cursor instance at 0x0248DF30>, <pypyodbc.Connection instance at 
0x025C5A30>, <pypyodbc.Cursor instance at 0x025F7850>, <pypyodbc.Connection 
instance at 0x025CEC38>, <pypyodbc.Cursor instance at 0x025F76E8>, 
<pypyodbc.Connection instance at 0x024BC7B0>, <pypyodbc.Cursor instance at 
0x025F79E0>]
# ---

Original comment by [email protected] on 17 Oct 2013 at 11:32

from pypyodbc.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 19, 2024
fixed in version 1.2.1, thanks for reporting

Original comment by [email protected] on 16 Nov 2013 at 3:43

  • Changed state: Fixed

from pypyodbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.