|
5 | 5 |
|
6 | 6 | import datetime
|
7 | 7 | import multiprocessing
|
| 8 | +import subprocess |
8 | 9 | import time
|
9 | 10 | from typing import List
|
10 | 11 |
|
@@ -901,6 +902,33 @@ def test_stop_server_inline_persistent():
|
901 | 902 | proc.terminate()
|
902 | 903 |
|
903 | 904 |
|
| 905 | +def test_showdash_not_hanging_when_port_in_use(): |
| 906 | + if not_on_linux(): |
| 907 | + pytest.skip("This test is currently only supported on linux") |
| 908 | + |
| 909 | + port = 8032 |
| 910 | + |
| 911 | + start_fig = "from plotly_resampler import FigureResampler; " |
| 912 | + start_fig += ( |
| 913 | + f"FigureResampler().show_dash(mode='external', port={port}, debug=False)" |
| 914 | + ) |
| 915 | + |
| 916 | + # Start the first figure in another python interpreter |
| 917 | + p1 = subprocess.Popen(["python", "-c", start_fig]) |
| 918 | + # Wait a little bit |
| 919 | + time.sleep(3) |
| 920 | + |
| 921 | + # Start the second figure in the current python interpreter |
| 922 | + with pytest.raises(SystemExit): |
| 923 | + # Start the second figure |
| 924 | + FigureResampler().show_dash(mode="external", port=port) |
| 925 | + # Wait a little bit |
| 926 | + time.sleep(3) |
| 927 | + |
| 928 | + # Stop the first figure |
| 929 | + p1.kill() |
| 930 | + |
| 931 | + |
904 | 932 | def test_manual_jupyterdashpersistentinline():
|
905 | 933 | # Manually call the JupyterDashPersistentInline its method
|
906 | 934 | # This requires some gimmicky stuff to mimmick the behaviour of a jupyter notebook.
|
@@ -1336,7 +1364,7 @@ def check_data(fr: FigureResampler, min_v=0, max_v=nb_datapoints - 1):
|
1336 | 1364 |
|
1337 | 1365 | if not_on_linux():
|
1338 | 1366 | # TODO: eventually we should run this test on Windows & MacOS too
|
1339 |
| - return |
| 1367 | + pytest.skip("This test is currently only run on Linux") |
1340 | 1368 |
|
1341 | 1369 | f_pr.stop_server()
|
1342 | 1370 | proc = multiprocessing.Process(target=f_pr.show_dash, kwargs=dict(mode="external"))
|
@@ -1424,7 +1452,7 @@ def check_data(fr: FigureResampler, min_v=0, max_v=nb_datapoints - 1):
|
1424 | 1452 |
|
1425 | 1453 | if not_on_linux():
|
1426 | 1454 | # TODO: eventually we should run this test on Windows & MacOS too
|
1427 |
| - return |
| 1455 | + pytest.skip("This test is currently only run on Linux") |
1428 | 1456 |
|
1429 | 1457 | f_pr.stop_server()
|
1430 | 1458 | proc = multiprocessing.Process(target=f_pr.show_dash, kwargs=dict(mode="external"))
|
|
0 commit comments