DEVART ODBC drivers not python thread safe

Discussion of open issues, suggestions and bugs regarding usage of ODBC Drivers
Post Reply
gerham
Posts: 12
Joined: Thu 22 Sep 2016 23:58

DEVART ODBC drivers not python thread safe

Post by gerham » Mon 07 Aug 2017 23:59

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))

gerham
Posts: 12
Joined: Thu 22 Sep 2016 23:58

Re: DEVART ODBC drivers not python thread safe

Post by gerham » Tue 08 Aug 2017 00:00

I forgot to mention we use the ASE drivers, single user on a macOS and the Server DEVART ODBC drivers version on LINUX

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: DEVART ODBC drivers not python thread safe

Post by MaximG » Fri 11 Aug 2017 08:58

Сurrently our driver is not thread-safe. We will consider the possibility of implementing this behavior in one of the next our product releases.

gerham
Posts: 12
Joined: Thu 22 Sep 2016 23:58

Re: DEVART ODBC drivers not python thread safe

Post by gerham » Fri 11 Aug 2017 13:03

Thank you for the confirmation.

Post Reply