Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
ce2b60ec
Kaydet (Commit)
ce2b60ec
authored
Tem 13, 2016
tarafından
Aanand Prasad
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Document all socket utility methods
Signed-off-by:
Aanand Prasad
<
aanand.prasad@gmail.com
>
üst
3e2f4a61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
socket.py
docker/utils/socket.py
+14
-2
No files found.
docker/utils/socket.py
Dosyayı görüntüle @
ce2b60ec
...
...
@@ -11,7 +11,9 @@ class SocketError(Exception):
def
read_socket
(
socket
,
n
=
4096
):
""" Code stolen from dockerpty to read the socket """
"""
Reads at most n bytes from socket
"""
recoverable_errors
=
(
errno
.
EINTR
,
errno
.
EDEADLK
,
errno
.
EWOULDBLOCK
)
# wait for data to become available
...
...
@@ -27,8 +29,12 @@ def read_socket(socket, n=4096):
def
next_packet_size
(
socket
):
""" Code stolen from dockerpty to get the next packet size """
"""
Returns the size of the next frame of data waiting to be read from socket,
according to the protocol defined here:
https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/attach-to-a-container
"""
try
:
data
=
read_data
(
socket
,
8
)
except
SocketError
:
...
...
@@ -39,6 +45,9 @@ def next_packet_size(socket):
def
read_data
(
socket
,
n
):
"""
Reads exactly n bytes from socket
"""
data
=
six
.
binary_type
()
while
len
(
data
)
<
n
:
next_data
=
read_socket
(
socket
,
n
-
len
(
data
))
...
...
@@ -49,6 +58,9 @@ def read_data(socket, n):
def
read_iter
(
socket
):
"""
Returns a generator of frames read from socket
"""
n
=
next_packet_size
(
socket
)
while
n
>
0
:
yield
read_socket
(
socket
,
n
)
...
...
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