You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The basic problem is that MonetDBe-Python does not allow multiple concurrent connections. It uses class level state in the class Frontend (_active_context) to ensure that. The first thread that connects, gets a connection which is closed by the second thread that connects.
I think that this is a remnant from the time we assumed only one connection at a time in a MonetDBe process.
But this can now be relaxed. Take a look at this MonetDBe native example for how this can be done with pthreads.
When this is fixed, I expect something like the following Python code to work:
import monetdbe
import concurrent.futures
monet_conn_1 = monetdbe.connect("devdb", autocommit=True)
monet_conn_1.execute("CREATE TABLE foo (i INT);")
def write_table():
monet_conn_2 = monetdbe.connect("devdb", autocommit=True)
n = 0
while n < 10:
print("write_table")
monet_conn_2.execute("INSERT INTO foo VALUES (10);")
n=n+1
def read_table():
monet_conn_3 = monetdbe.connect("devdb", autocommit=True)
n = 0
while n < 10:
print("read_table")
monet_conn_3.cursor().execute("SELECT * FROM foo;")
print(len(monet_conn_3.cursor().fetchall()))
n=n+1
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.submit(write_table)
executor.submit(read_table)
The text was updated successfully, but these errors were encountered:
The basic problem is that MonetDBe-Python does not allow multiple concurrent connections. It uses class level state in the class
Frontend
(_active_context
) to ensure that. The first thread that connects, gets a connection which is closed by the second thread that connects.I think that this is a remnant from the time we assumed only one connection at a time in a MonetDBe process.
But this can now be relaxed. Take a look at this MonetDBe native example for how this can be done with pthreads.
When this is fixed, I expect something like the following Python code to work:
The text was updated successfully, but these errors were encountered: