mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-29 12:23:42 +03:00
Added test to reproduce ticket #829
Unrelated processes close the FD of the connection. This happens in Python 3.6 but not 2.7. Let's see if travis shows where else it fails...
This commit is contained in:
parent
b4b470c29a
commit
7c5afd6977
|
@ -357,6 +357,34 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
conn.close()
|
conn.close()
|
||||||
self.assert_(conn.pgconn_ptr is None)
|
self.assert_(conn.pgconn_ptr is None)
|
||||||
|
|
||||||
|
@slow
|
||||||
|
def test_multiprocess_close(self):
|
||||||
|
script = ("""\
|
||||||
|
import time
|
||||||
|
import threading
|
||||||
|
import multiprocessing
|
||||||
|
import psycopg2
|
||||||
|
|
||||||
|
def thread():
|
||||||
|
conn = psycopg2.connect(%(dsn)r)
|
||||||
|
curs = conn.cursor()
|
||||||
|
for i in range(10):
|
||||||
|
curs.execute("select 1")
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
def process():
|
||||||
|
time.sleep(0.2)
|
||||||
|
|
||||||
|
t = threading.Thread(target=thread, name='mythread')
|
||||||
|
t.start()
|
||||||
|
time.sleep(0.2)
|
||||||
|
multiprocessing.Process(target=process, name='myprocess').start()
|
||||||
|
t.join()
|
||||||
|
""" % {'dsn': dsn})
|
||||||
|
|
||||||
|
out = sp.check_output([sys.executable, '-c', script], stderr=sp.STDOUT)
|
||||||
|
self.assertEqual(out, b'', out.decode('ascii'))
|
||||||
|
|
||||||
|
|
||||||
class ParseDsnTestCase(ConnectingTestCase):
|
class ParseDsnTestCase(ConnectingTestCase):
|
||||||
def test_parse_dsn(self):
|
def test_parse_dsn(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user