Skip to content

Commit af10552

Browse files
authored
Merge pull request #67 from Worvast/master
Fixed reconnection to socket in every send instruction of Sender
2 parents 9136c2b + aaaeef7 commit af10552

File tree

6 files changed

+31
-19
lines changed

6 files changed

+31
-19
lines changed

.pep8speaks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# File : .pep8speaks.yml
2+
3+
scanner:
4+
diff_only: True # Errors caused by only the patch are shown

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77

8+
## [3.0.3] - 2019-09-25
9+
#### Fixed
10+
* Fixed reconnection to socket in every send instruction of Sender
11+
* Code style changes
12+
* Added pep8speaks file for Github
13+
14+
815
## [3.0.2] - 2019-07-01
916
#### Fixed
1017
* API dates when int, verify if len its correct before add 3 zero

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[![master Build Status](https://travis-ci.com/DevoInc/python-sdk.svg?branch=master)](https://travis-ci.com/DevoInc/python-sdk) [![LICENSE](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/DevoInc/python-sdk/blob/master/LICENSE)
33

4-
[![wheel](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.org/project/devo-sdk/) [![version](https://img.shields.io/badge/version-3.0.2-blue.svg)](https://pypi.org/project/devo-sdk/) [![python](https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7-blue.svg)](https://pypi.org/project/devo-sdk/)
4+
[![wheel](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.org/project/devo-sdk/) [![version](https://img.shields.io/badge/version-3.0.3-blue.svg)](https://pypi.org/project/devo-sdk/) [![python](https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7-blue.svg)](https://pypi.org/project/devo-sdk/)
55

66

77
# Devo Python SDK

devo/__version__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__description__ = 'Devo Python Library.'
22
__url__ = 'http://www.devo.com'
3-
__version__ = "3.0.2"
3+
__version__ = "3.0.3"
44
__author__ = 'Devo'
55
__author_email__ = 'support@devo.com'
66
__license__ = 'MIT'
7-
__copyright__ = 'Copyright 2018 Devo'
7+
__copyright__ = 'Copyright 2019 Devo'

devo/api/client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,15 @@ def _is_correct_response(line):
237237
except ValueError:
238238
return False
239239

240-
def configurate(self, processor=None, response=None, stream=None,
241-
destination=None):
242-
240+
def configurate(self, processor=None, response=None,
241+
destination=None, stream=True):
242+
"""
243+
Method for fill Configuration options more easy
244+
:param processor: processor for response, default is None
245+
:param response: format of response
246+
:param destination: Destination options, see Doc for more info
247+
:param stream: Stream queries or not
248+
"""
243249
self.config.set_processor(processor)
244250
if response:
245251
self.config.response = response

devo/sender/data.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class SenderConfigSSL:
4242
Sender
4343
4444
"""
45-
4645
def __init__(self, address=None, key=None, cert=None, chain=None):
4746
if not isinstance(address, tuple):
4847
raise DevoSenderException(
@@ -63,14 +62,12 @@ def __init__(self, address=None, key=None, cert=None, chain=None):
6362
class SenderConfigTCP:
6463
"""
6564
Configuration TCP class.
65+
:param address:(tuple) Server address and port
6666
67-
:param address:(str) Server address
68-
69-
>>>sender_config = SenderConfigTCP(address=SERVER, port=PORT)
67+
>>>sender_config = SenderConfigTCP(address=(ADDRESS, PORT))
7068
7169
See Also:
7270
Sender
73-
7471
"""
7572

7673
def __init__(self, address=None):
@@ -107,8 +104,7 @@ class Sender(logging.Handler):
107104
:param logger: logger. Default sys.console
108105
"""
109106
def __init__(self, config=None, con_type=None,
110-
timeout=10, debug=False, logger=None):
111-
107+
timeout=30, debug=False, logger=None):
112108
if config is None:
113109
raise DevoSenderException("Problems with args passed to Sender")
114110

@@ -127,7 +123,8 @@ def __init__(self, config=None, con_type=None,
127123
self._sender_config = config
128124
self.reconnection = 0
129125
self.debug = debug
130-
self.timeout = timeout
126+
self.socket_timeout = timeout
127+
self.socket_max_connection = 3600 * 1000
131128
self.buffer = SenderBuffer()
132129
self.logging = {}
133130

@@ -149,7 +146,7 @@ def __connect_tcp_socket(self):
149146
:return:
150147
"""
151148
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
152-
self.socket.settimeout(self.timeout)
149+
self.socket.settimeout(self.socket_timeout)
153150
try:
154151
self.socket.connect(self._sender_config.address)
155152
except socket.error as error:
@@ -165,7 +162,7 @@ def __connect_ssl(self):
165162
166163
"""
167164
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
168-
self.socket.settimeout(self.timeout)
165+
self.socket.settimeout(self.socket_timeout)
169166

170167
try:
171168
try:
@@ -214,10 +211,8 @@ def __status(self):
214211
timeit = int(round(time.time() * 1000)) - self.timestart
215212
if self.socket is None:
216213
return False
217-
if not self.timeout:
218-
self.timeout = 10
219214

220-
if self.timeout < timeit:
215+
if self.socket_max_connection < timeit:
221216
self.close()
222217
return False
223218
return True

0 commit comments

Comments
 (0)