1
# Copyright 2014-2015 MongoDB, Inc.
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
15
"""Represent a response from the server."""
18
class Response(object):
19
__slots__ = ('_data', '_address')
21
def __init__(self, data, address):
22
"""Represent a response from the server.
25
- `data`: Raw BSON bytes.
26
- `address`: (host, port) of the source server.
29
self._address = address
33
"""Server response's raw BSON bytes."""
38
"""(host, port) of the source server."""
42
class ExhaustResponse(Response):
43
__slots__ = ('_socket_info', '_pool')
45
def __init__(self, data, address, socket_info, pool):
46
"""Represent a response to an exhaust cursor's initial query.
49
- `data`: Raw BSON bytes.
50
- `address`: (host, port) of the source server.
51
- `socket_info`: The SocketInfo used for the initial query.
52
- `pool`: The Pool from which the SocketInfo came.
54
super(ExhaustResponse, self).__init__(data, address)
55
self._socket_info = socket_info
59
def socket_info(self):
60
"""The SocketInfo used for the initial query.
62
The server will send batches on this socket, without waiting for
63
getMores from the client, until the result set is exhausted or there
66
return self._socket_info
70
"""The Pool from which the SocketInfo came."""