Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Strand Lab
Strand Lab Cellxgene Gateway
Commits
455e0cd0
Commit
455e0cd0
authored
Oct 29, 2019
by
Alok Saldanha
Browse files
#9 skip ports that are in use
parent
c937f907
Changes
1
Hide whitespace changes
Inline
Side-by-side
cellxgene_gateway/backend_cache.py
View file @
455e0cd0
...
...
@@ -20,6 +20,11 @@ from cellxgene_gateway.subprocess_backend import SubprocessBackend
process_backend
=
SubprocessBackend
()
def
is_port_in_use
(
port
):
import
socket
with
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
as
s
:
return
s
.
connect_ex
((
'localhost'
,
port
))
==
0
class
BackendCache
:
def
__init__
(
self
):
self
.
entry_list
=
[]
...
...
@@ -49,7 +54,7 @@ class BackendCache:
def
create_entry
(
self
,
dataset
,
file_path
,
scripts
):
port
=
8000
existing_ports
=
self
.
get_ports
()
while
port
in
existing_ports
:
while
(
port
in
existing_ports
)
or
is_port_in_use
(
port
)
:
port
+=
1
entry
=
CacheEntry
.
for_dataset
(
dataset
,
file_path
,
port
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment