File tree 1 file changed +11
-0
lines changed
plotly_resampler/figure_resampler
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 10
10
11
11
__author__ = "Jonas Van Der Donckt, Jeroen Van Der Donckt, Emiel Deprost"
12
12
13
+ import sys
14
+ import socket
13
15
import warnings
14
16
from typing import Tuple
15
17
@@ -160,6 +162,15 @@ def show_dash(
160
162
self ._host = kwargs .get ("host" , "127.0.0.1" )
161
163
self ._port = kwargs .get ("port" , "8050" )
162
164
165
+ # check if self._port is already in use
166
+ with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
167
+ if s .connect_ex (('localhost' , int (self ._port ))) == 0 :
168
+ error_message = "Address already in use\n " \
169
+ f"Port { self ._port } is in use by another program. " \
170
+ "Either identify and stop that program, or start the server with a different port."
171
+ print (error_message )
172
+ sys .exit (1 )
173
+
163
174
app .run_server (mode = mode , ** kwargs )
164
175
165
176
def stop_server (self , warn : bool = True ):
You can’t perform that action at this time.
0 commit comments