+52
-2
lines changedFilter options
+52
-2
lines changed Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
14
14
from psycopg.conninfo import conninfo_to_dict, make_conninfo
15
15
16
16
from .utils import gc_collect
17
-
from .acompat import is_async, skip_sync, skip_async
17
+
from .acompat import sleep, spawn, gather, is_async, skip_sync, skip_async
18
18
from ._test_cursor import my_row_factory
19
19
from ._test_connection import tx_params, tx_params_isolation, tx_values_map
20
20
from ._test_connection import conninfo_params_timeout
@@ -824,3 +824,28 @@ def test_connect_context_copy(conn_cls, dsn, conn):
824
824
def test_cancel_closed(conn):
825
825
conn.close()
826
826
conn.cancel()
827
+
828
+
829
+
@pytest.mark.slow
830
+
@pytest.mark.timing
831
+
def test_proxy_disconnection(conn_cls, proxy):
832
+
proxy.start()
833
+
834
+
task = None
835
+
836
+
def closer():
837
+
sleep(0.5)
838
+
proxy.stop()
839
+
840
+
try:
841
+
with conn_cls.connect(proxy.client_dsn) as conn:
842
+
t0 = time.time()
843
+
task = spawn(closer)
844
+
with pytest.raises(psycopg.OperationalError):
845
+
conn.execute("select pg_sleep(1)")
846
+
finally:
847
+
dt = time.time() - t0
848
+
if task:
849
+
gather(task)
850
+
851
+
assert dt < 0.75
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
11
11
from psycopg.conninfo import conninfo_to_dict, make_conninfo
12
12
13
13
from .utils import gc_collect
14
-
from .acompat import is_async, skip_sync, skip_async
14
+
from .acompat import asleep, spawn, gather, is_async, skip_sync, skip_async
15
15
from ._test_cursor import my_row_factory
16
16
from ._test_connection import tx_params, tx_params_isolation, tx_values_map
17
17
from ._test_connection import conninfo_params_timeout
@@ -832,3 +832,28 @@ async def test_connect_context_copy(aconn_cls, dsn, aconn):
832
832
async def test_cancel_closed(aconn):
833
833
await aconn.close()
834
834
aconn.cancel()
835
+
836
+
837
+
@pytest.mark.slow
838
+
@pytest.mark.timing
839
+
async def test_proxy_disconnection(aconn_cls, proxy):
840
+
proxy.start()
841
+
842
+
task = None
843
+
844
+
async def closer():
845
+
await asleep(0.5)
846
+
proxy.stop()
847
+
848
+
try:
849
+
async with await aconn_cls.connect(proxy.client_dsn) as conn:
850
+
t0 = time.time()
851
+
task = spawn(closer)
852
+
with pytest.raises(psycopg.OperationalError):
853
+
await conn.execute("select pg_sleep(1)")
854
+
finally:
855
+
dt = time.time() - t0
856
+
if task:
857
+
await gather(task)
858
+
859
+
assert dt < 0.75
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4