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
9fc06b19
Kaydet (Commit)
9fc06b19
authored
Eki 14, 2016
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Eki 14, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1254 from docker/npipe-advanced
Several fixes to npipe support
üst
14634fb5
c76ec15d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
3 deletions
+44
-3
client.py
docker/client.py
+3
-1
__init__.py
docker/transport/__init__.py
+1
-0
npipeconn.py
docker/transport/npipeconn.py
+22
-1
npipesocket.py
docker/transport/npipesocket.py
+11
-1
socket.py
docker/utils/socket.py
+7
-0
No files found.
docker/client.py
Dosyayı görüntüle @
9fc06b19
...
@@ -220,7 +220,9 @@ class Client(
...
@@ -220,7 +220,9 @@ class Client(
def
_get_raw_response_socket
(
self
,
response
):
def
_get_raw_response_socket
(
self
,
response
):
self
.
_raise_for_status
(
response
)
self
.
_raise_for_status
(
response
)
if
six
.
PY3
:
if
self
.
base_url
==
"http+docker://localnpipe"
:
sock
=
response
.
raw
.
_fp
.
fp
.
raw
.
sock
elif
six
.
PY3
:
sock
=
response
.
raw
.
_fp
.
fp
.
raw
sock
=
response
.
raw
.
_fp
.
fp
.
raw
if
self
.
base_url
.
startswith
(
"https://"
):
if
self
.
base_url
.
startswith
(
"https://"
):
sock
=
sock
.
_sock
sock
=
sock
.
_sock
...
...
docker/transport/__init__.py
Dosyayı görüntüle @
9fc06b19
...
@@ -2,5 +2,6 @@
...
@@ -2,5 +2,6 @@
from
.unixconn
import
UnixAdapter
from
.unixconn
import
UnixAdapter
try
:
try
:
from
.npipeconn
import
NpipeAdapter
from
.npipeconn
import
NpipeAdapter
from
.npipesocket
import
NpipeSocket
except
ImportError
:
except
ImportError
:
pass
pass
docker/transport/npipeconn.py
Dosyayı görüntüle @
9fc06b19
...
@@ -14,7 +14,6 @@ try:
...
@@ -14,7 +14,6 @@ try:
except
ImportError
:
except
ImportError
:
import
urllib3
import
urllib3
RecentlyUsedContainer
=
urllib3
.
_collections
.
RecentlyUsedContainer
RecentlyUsedContainer
=
urllib3
.
_collections
.
RecentlyUsedContainer
...
@@ -46,6 +45,28 @@ class NpipeHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):
...
@@ -46,6 +45,28 @@ class NpipeHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):
self
.
npipe_path
,
self
.
timeout
self
.
npipe_path
,
self
.
timeout
)
)
# When re-using connections, urllib3 tries to call select() on our
# NpipeSocket instance, causing a crash. To circumvent this, we override
# _get_conn, where that check happens.
def
_get_conn
(
self
,
timeout
):
conn
=
None
try
:
conn
=
self
.
pool
.
get
(
block
=
self
.
block
,
timeout
=
timeout
)
except
AttributeError
:
# self.pool is None
raise
urllib3
.
exceptions
.
ClosedPoolError
(
self
,
"Pool is closed."
)
except
six
.
moves
.
queue
.
Empty
:
if
self
.
block
:
raise
urllib3
.
exceptions
.
EmptyPoolError
(
self
,
"Pool reached maximum size and no more "
"connections are allowed."
)
pass
# Oh well, we'll create a new connection then
return
conn
or
self
.
_new_conn
()
class
NpipeAdapter
(
requests
.
adapters
.
HTTPAdapter
):
class
NpipeAdapter
(
requests
.
adapters
.
HTTPAdapter
):
def
__init__
(
self
,
base_url
,
timeout
=
60
,
def
__init__
(
self
,
base_url
,
timeout
=
60
,
...
...
docker/transport/npipesocket.py
Dosyayı görüntüle @
9fc06b19
import
functools
import
functools
import
io
import
io
import
six
import
win32file
import
win32file
import
win32pipe
import
win32pipe
...
@@ -95,7 +96,7 @@ class NpipeSocket(object):
...
@@ -95,7 +96,7 @@ class NpipeSocket(object):
if
mode
.
strip
(
'b'
)
!=
'r'
:
if
mode
.
strip
(
'b'
)
!=
'r'
:
raise
NotImplementedError
()
raise
NotImplementedError
()
rawio
=
NpipeFileIOBase
(
self
)
rawio
=
NpipeFileIOBase
(
self
)
if
bufsize
is
None
or
bufsize
<
0
:
if
bufsize
is
None
or
bufsize
<
=
0
:
bufsize
=
io
.
DEFAULT_BUFFER_SIZE
bufsize
=
io
.
DEFAULT_BUFFER_SIZE
return
io
.
BufferedReader
(
rawio
,
buffer_size
=
bufsize
)
return
io
.
BufferedReader
(
rawio
,
buffer_size
=
bufsize
)
...
@@ -115,6 +116,9 @@ class NpipeSocket(object):
...
@@ -115,6 +116,9 @@ class NpipeSocket(object):
@check_closed
@check_closed
def
recv_into
(
self
,
buf
,
nbytes
=
0
):
def
recv_into
(
self
,
buf
,
nbytes
=
0
):
if
six
.
PY2
:
return
self
.
_recv_into_py2
(
buf
,
nbytes
)
readbuf
=
buf
readbuf
=
buf
if
not
isinstance
(
buf
,
memoryview
):
if
not
isinstance
(
buf
,
memoryview
):
readbuf
=
memoryview
(
buf
)
readbuf
=
memoryview
(
buf
)
...
@@ -125,6 +129,12 @@ class NpipeSocket(object):
...
@@ -125,6 +129,12 @@ class NpipeSocket(object):
)
)
return
len
(
data
)
return
len
(
data
)
def
_recv_into_py2
(
self
,
buf
,
nbytes
):
err
,
data
=
win32file
.
ReadFile
(
self
.
_handle
,
nbytes
or
len
(
buf
))
n
=
len
(
data
)
buf
[:
n
]
=
data
return
n
@check_closed
@check_closed
def
send
(
self
,
string
,
flags
=
0
):
def
send
(
self
,
string
,
flags
=
0
):
err
,
nbytes
=
win32file
.
WriteFile
(
self
.
_handle
,
string
)
err
,
nbytes
=
win32file
.
WriteFile
(
self
.
_handle
,
string
)
...
...
docker/utils/socket.py
Dosyayı görüntüle @
9fc06b19
...
@@ -5,6 +5,11 @@ import struct
...
@@ -5,6 +5,11 @@ import struct
import
six
import
six
try
:
from
..transport
import
NpipeSocket
except
ImportError
:
NpipeSocket
=
type
(
None
)
class
SocketError
(
Exception
):
class
SocketError
(
Exception
):
pass
pass
...
@@ -14,9 +19,11 @@ def read(socket, n=4096):
...
@@ -14,9 +19,11 @@ def read(socket, n=4096):
"""
"""
Reads at most n bytes from socket
Reads at most n bytes from socket
"""
"""
recoverable_errors
=
(
errno
.
EINTR
,
errno
.
EDEADLK
,
errno
.
EWOULDBLOCK
)
recoverable_errors
=
(
errno
.
EINTR
,
errno
.
EDEADLK
,
errno
.
EWOULDBLOCK
)
# wait for data to become available
# wait for data to become available
if
not
isinstance
(
socket
,
NpipeSocket
):
select
.
select
([
socket
],
[],
[])
select
.
select
([
socket
],
[],
[])
try
:
try
:
...
...
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