mirror of https://github.com/docker/docker-py.git
Merge branch 'docker:main' into main
This commit is contained in:
commit
8ca9c6394f
|
@ -1164,8 +1164,9 @@ class ContainerApiMixin:
|
|||
'one_shot is only available in conjunction with '
|
||||
'stream=False'
|
||||
)
|
||||
return self._stream_helper(self._get(url, params=params),
|
||||
decode=decode)
|
||||
return self._stream_helper(
|
||||
self._get(url, stream=True, params=params), decode=decode
|
||||
)
|
||||
else:
|
||||
if decode:
|
||||
raise errors.InvalidArgument(
|
||||
|
|
|
@ -4,6 +4,9 @@ import io
|
|||
|
||||
import win32file
|
||||
import win32pipe
|
||||
import pywintypes
|
||||
import win32event
|
||||
import win32api
|
||||
|
||||
cERROR_PIPE_BUSY = 0xe7
|
||||
cSECURITY_SQOS_PRESENT = 0x100000
|
||||
|
@ -54,7 +57,9 @@ class NpipeSocket:
|
|||
0,
|
||||
None,
|
||||
win32file.OPEN_EXISTING,
|
||||
cSECURITY_ANONYMOUS | cSECURITY_SQOS_PRESENT,
|
||||
(cSECURITY_ANONYMOUS
|
||||
| cSECURITY_SQOS_PRESENT
|
||||
| win32file.FILE_FLAG_OVERLAPPED),
|
||||
0
|
||||
)
|
||||
except win32pipe.error as e:
|
||||
|
@ -131,22 +136,37 @@ class NpipeSocket:
|
|||
if not isinstance(buf, memoryview):
|
||||
readbuf = memoryview(buf)
|
||||
|
||||
err, data = win32file.ReadFile(
|
||||
self._handle,
|
||||
readbuf[:nbytes] if nbytes else readbuf
|
||||
)
|
||||
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
|
||||
event = win32event.CreateEvent(None, True, True, None)
|
||||
try:
|
||||
overlapped = pywintypes.OVERLAPPED()
|
||||
overlapped.hEvent = event
|
||||
err, data = win32file.ReadFile(
|
||||
self._handle,
|
||||
readbuf[:nbytes] if nbytes else readbuf,
|
||||
overlapped
|
||||
)
|
||||
wait_result = win32event.WaitForSingleObject(event, self._timeout)
|
||||
if wait_result == win32event.WAIT_TIMEOUT:
|
||||
win32file.CancelIo(self._handle)
|
||||
raise TimeoutError
|
||||
return win32file.GetOverlappedResult(self._handle, overlapped, 0)
|
||||
finally:
|
||||
win32api.CloseHandle(event)
|
||||
|
||||
@check_closed
|
||||
def send(self, string, flags=0):
|
||||
err, nbytes = win32file.WriteFile(self._handle, string)
|
||||
return nbytes
|
||||
event = win32event.CreateEvent(None, True, True, None)
|
||||
try:
|
||||
overlapped = pywintypes.OVERLAPPED()
|
||||
overlapped.hEvent = event
|
||||
win32file.WriteFile(self._handle, string, overlapped)
|
||||
wait_result = win32event.WaitForSingleObject(event, self._timeout)
|
||||
if wait_result == win32event.WAIT_TIMEOUT:
|
||||
win32file.CancelIo(self._handle)
|
||||
raise TimeoutError
|
||||
return win32file.GetOverlappedResult(self._handle, overlapped, 0)
|
||||
finally:
|
||||
win32api.CloseHandle(event)
|
||||
|
||||
@check_closed
|
||||
def sendall(self, string, flags=0):
|
||||
|
@ -165,15 +185,12 @@ class NpipeSocket:
|
|||
def settimeout(self, value):
|
||||
if value is None:
|
||||
# Blocking mode
|
||||
self._timeout = win32pipe.NMPWAIT_WAIT_FOREVER
|
||||
self._timeout = win32event.INFINITE
|
||||
elif not isinstance(value, (float, int)) or value < 0:
|
||||
raise ValueError('Timeout value out of range')
|
||||
elif value == 0:
|
||||
# Non-blocking mode
|
||||
self._timeout = win32pipe.NMPWAIT_NO_WAIT
|
||||
else:
|
||||
# Timeout mode - Value converted to milliseconds
|
||||
self._timeout = value * 1000
|
||||
self._timeout = int(value * 1000)
|
||||
|
||||
def gettimeout(self):
|
||||
return self._timeout
|
||||
|
|
|
@ -37,7 +37,7 @@ def read(socket, n=4096):
|
|||
select.select([socket], [], [])
|
||||
else:
|
||||
poll = select.poll()
|
||||
poll.register(socket)
|
||||
poll.register(socket, select.POLLIN | select.POLLPRI)
|
||||
poll.poll()
|
||||
|
||||
try:
|
||||
|
|
|
@ -1,6 +1,47 @@
|
|||
Changelog
|
||||
==========
|
||||
|
||||
6.1.2
|
||||
-----
|
||||
|
||||
#### Bugfixes
|
||||
- Fix for socket timeouts on long `docker exec` calls
|
||||
|
||||
6.1.1
|
||||
-----
|
||||
|
||||
#### Bugfixes
|
||||
- Fix `containers.stats()` hanging with `stream=True`
|
||||
- Correct return type in docs for `containers.diff()` method
|
||||
|
||||
|
||||
6.1.0
|
||||
-----
|
||||
|
||||
### Upgrade Notes
|
||||
- Errors are no longer returned during client initialization if the credential helper cannot be found. A warning will be emitted instead, and an error is returned if the credential helper is used.
|
||||
|
||||
### Features
|
||||
- Python 3.11 support
|
||||
- Use `poll()` instead of `select()` on non-Windows platforms
|
||||
- New API fields
|
||||
- `network_driver_opt` on container run / create
|
||||
- `one-shot` on container stats
|
||||
- `status` on services list
|
||||
|
||||
### Bugfixes
|
||||
- Support for requests 2.29.0+ and urllib3 2.x
|
||||
- Do not strip characters from volume names
|
||||
- Fix connection leak on container.exec_* operations
|
||||
- Fix errors closing named pipes on Windows
|
||||
|
||||
6.0.1
|
||||
-----
|
||||
|
||||
### Bugfixes
|
||||
- Fix for `The pipe has been ended errors` on Windows
|
||||
- Support floats for container log filtering by timestamp (`since` / `until`)
|
||||
|
||||
6.0.0
|
||||
-----
|
||||
|
||||
|
|
|
@ -1528,10 +1528,21 @@ class ContainerTest(BaseAPIClientTest):
|
|||
fake_request.assert_called_with(
|
||||
'GET',
|
||||
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stats',
|
||||
stream=True,
|
||||
timeout=60,
|
||||
params={'stream': True}
|
||||
)
|
||||
|
||||
def test_container_stats_without_streaming(self):
|
||||
self.client.stats(fake_api.FAKE_CONTAINER_ID, stream=False)
|
||||
|
||||
fake_request.assert_called_with(
|
||||
'GET',
|
||||
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stats',
|
||||
timeout=60,
|
||||
params={'stream': False}
|
||||
)
|
||||
|
||||
def test_container_stats_with_one_shot(self):
|
||||
self.client.stats(
|
||||
fake_api.FAKE_CONTAINER_ID, stream=False, one_shot=True)
|
||||
|
|
Loading…
Reference in New Issue