Delay when Exiting Process after using pyodbc (Windows Server 2008R2, pyodbc 4.0.22)

10 views
Skip to first unread message

Light O'Matic

unread,
Jan 25, 2018, 4:25:02 PM1/25/18
to pyodbc

Hi, I have an issue where, after the using pyodbc, it takes several seconds for my process to exit.
The rest of the process runs quickly.. eg.. connect to database, execute the query, read the result, and close.. all finish in a fraction of a second.  But then, sys.exit() takes several seconds, which is causing a problem.

I'm using python 3.6 on Windows Server 2008R2 and the database is Pervasive 10.20.20 (not my choice.. it is part of the Sage 50 accounting system).
And I should mention, python is 32 bit because the Pervasive ODBC driver is 32 bit so it won't work otherwise.

My test code is below, any ideas would be appreciated, thanks!
Ben

#!python
import pyodbc, sys

db = pyodbc.connect('DSN=SSBCPEACH;UID=Peachtree;PWD=password')

cursor = db.cursor()
cursor.execute("""SELECT glacntnumber, accountdescription, accountid, accounttype FROM chart WHERE accountid = ? """, '10222')
account = cursor.fetchone()

if account is not None:
    print("Found Account: AccountID '%s', AccountDescription '%s', AccountType '%s', GLAcntNumber '%s'." % (
        account.AccountID, account.AccountDescription, account.AccountType, account.GLAcntNumber))

db.close()
print('closed')

# EXIT TAKES APPROX 3 SECONDS, only if I've connected to the database.
sys.exit(0)



dwie...@gmail.com

unread,
May 30, 2018, 4:16:48 PM5/30/18
to pyodbc
You have probably solved your problem by now, but if you haven't you might try adding

db = None

after the db.close()

Dave

Reply all
Reply to author
Forward
0 new messages