We have worked out that the DEVART Mac/LINUX drivers are not thread safe.
A long-running query that works fine in interactive python will likely lead to a segmentation fault when run via normal python. The difference being normal python is multithreaded, with python yielding when it's waiting for a response from sybase/odbc...
# test script for Sybase ODBC
# Python 3
import pyodbc
from multiprocessing.dummy import Pool as ThreadPool
pool = ThreadPool(4)
def doSQL(sql):
print(sql)
cnxn = pyodbc.connect('DSN=syb_testabr;UID=user1;PWD=blahblah')
cnxn.setencoding(encoding='utf-8')
crsr = cnxn.cursor()
return crsr.execute(sql).fetchall()
# query & select UTF8
print(doSQL("select * from line where shortlinename like '%∆%'"))
# select text type data
print(doSQL("select * from usage where employeeid='user1'"))
# convert TEXT to varchar
print(doSQL("select convert(varchar(8000),sessionvariablesxml) as xml from usage where employeeid='user1'"))
# convert TEXT to varchar to TEXT
print(doSQL("select convert(text,convert(varchar(8000),sessionvariablesxml)) as xml from usage where employeeid='user1'"))
#check multi-thread safe
sqls = [
"select * from line where shortlinename like '%∆%'",
"select * from usage where employeeid='user1'",
"select convert(varchar(8000),sessionvariablesxml) as xml from usage where employeeid='user1'",
"select convert(text,convert(varchar(8000),sessionvariablesxml)) as xml from usage where employeeid='user1'",
"select * from usage"
]
results = pool.map(doSQL,sqls)
pool.close()
pool.join()
print(len(results))
DEVART ODBC drivers not python thread safe
Re: DEVART ODBC drivers not python thread safe
I forgot to mention we use the ASE drivers, single user on a macOS and the Server DEVART ODBC drivers version on LINUX
Re: DEVART ODBC drivers not python thread safe
Сurrently our driver is not thread-safe. We will consider the possibility of implementing this behavior in one of the next our product releases.
Re: DEVART ODBC drivers not python thread safe
Thank you for the confirmation.