Skip to content

Commit 1ad77c6

Browse files
authored
Merge branch 'master' into AleksandrKandrashev/fix-proxies
2 parents 5ce9152 + 603632f commit 1ad77c6

File tree

8 files changed

+20
-35
lines changed

8 files changed

+20
-35
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414
- name: Install Python 3
1515
uses: actions/setup-python@v3
1616
with:
17-
python-version: 3.8
17+
python-version: 3.9
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
2121
pip install -r requirements.txt
2222
pip install python-dateutil backoff monotonic
2323
pip install --user .
24-
sudo pip install pylint==2.8.0 flake8 mock==3.0.5 python-dateutil aiohttp==3.9.1
24+
sudo pip install pylint==3.3.1 flake8 mock==3.0.5 python-dateutil aiohttp==3.9.1
2525
- name: Run tests
2626
run: python -m unittest discover -s segment
2727

@@ -41,17 +41,11 @@ jobs:
4141
# runs-on: ubuntu-latest
4242
# strategy:
4343
# matrix:
44-
# python: ['3.7', '3.8', '3.9', '3.10', '3.11']
44+
# python: ['3.9', '3.10', '3.11']
4545
# coverage: [false]
4646
# experimental: [false]
4747
# include:
4848
# # Run code coverage.
49-
# - python: '3.7'
50-
# coverage: true
51-
# experimental: false
52-
# - python: '3.8'
53-
# coverage: true
54-
# experimental: false
5549
# - python: '3.9'
5650
# coverage: true
5751
# experimental: false

.github/workflows/tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ jobs:
1919
- name: Checkout
2020
uses: actions/checkout@v4
2121

22-
- name: Run with setup-python 3.8
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: '3.8'
26-
- name: Setup required modules
27-
run: python -m pip install -r requirements.txt
28-
- name: Run tests
29-
run: python -m unittest discover -s segment
30-
3122
- name: Run with setup-python 3.9
3223
uses: actions/setup-python@v5
3324
with:

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2.3.3 / 2024-10-07
2+
- Update time handling and OAuth
3+
14
# 2.3.2 / 2024-02-15
25
- Updating version to create a release wheel without the outdated /analytics files
36

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
backoff==2.2.1
2-
cryptography==43.0.1
2+
cryptography==43.0.3
33
flake8==7.1.1
44
mock==2.0.0
5-
pylint==3.2.7
6-
PyJWT==2.9.0
5+
pylint==3.3.2
6+
PyJWT==2.10.1
77
python-dateutil==2.8.2
88
requests==2.32.3

segment/analytics/oauth_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ def _poller_loop(self):
152152

153153
elif response.status_code == 429:
154154
self.retry_count += 1
155-
rate_limit_reset_timestamp = None
155+
rate_limit_reset_time = None
156156
try:
157-
rate_limit_reset_timestamp = int(response.headers.get("X-RateLimit-Reset"))
157+
rate_limit_reset_time = int(response.headers.get("X-RateLimit-Reset"))
158158
except Exception as e:
159159
self.log.error("OAuth rate limit response did not have a valid rest time: {} | {}".format(response, e))
160-
if rate_limit_reset_timestamp:
161-
refresh_timer_ms = rate_limit_reset_timestamp - time.time() * 1000
160+
if rate_limit_reset_time:
161+
refresh_timer_ms = rate_limit_reset_time * 1000
162162
else:
163163
refresh_timer_ms = 5 * 1000
164164

segment/analytics/test/test_oauth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def json(self):
5555
elif kwargs['url'] == 'http://127.0.0.1:400/token':
5656
return MockResponse({"reason": "test_reason", "json_data" : {"error":"unrecoverable", "error_description":"nah"}}, 400)
5757
elif kwargs['url'] == 'http://127.0.0.1:429/token':
58-
return MockResponse({"reason": "test_reason", "headers" : {"X-RateLimit-Reset": time.time()*1000 + 2000}}, 429)
58+
return MockResponse({"reason": "test_reason", "headers" : {"X-RateLimit-Reset": 234}}, 429)
5959
elif kwargs['url'] == 'http://127.0.0.1:500/token':
6060
return MockResponse({"reason": "test_reason", "json_data" : {"error":"recoverable", "error_description":"nah"}}, 500)
6161
elif kwargs['url'] == 'http://127.0.0.1:501/token':
@@ -106,7 +106,7 @@ def test_oauth_fail_with_retries(self, mock_post):
106106
def test_oauth_rate_limit_delay(self, mock_sleep, mock_post):
107107
manager = segment.analytics.oauth_manager.OauthManager("id", privatekey, "keyid", "http://127.0.0.1:429")
108108
manager._poller_loop()
109-
self.assertTrue(mock_sleep.call_args[0][0] > 1.9 and mock_sleep.call_args[0][0] <= 2.0)
109+
mock_sleep.assert_called_with(234)
110110

111111
class TestOauthIntegration(unittest.TestCase):
112112
def fail(self, e, batch=[]):
@@ -152,4 +152,4 @@ def test_oauth_integration_fail_bad_key(self, mock_post):
152152
self.assertTrue(self.failed)
153153

154154
if __name__ == '__main__':
155-
unittest.main()
155+
unittest.main()

segment/analytics/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '2.3.2'
1+
VERSION = '2.3.3'

setup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"requests~=2.7",
2424
"backoff~=2.1",
2525
"python-dateutil~=2.2",
26-
"PyJWT~=2.8"
26+
"PyJWT~=2.10.1"
2727
]
2828

2929
tests_require = [
3030
"mock==2.0.0",
31-
"pylint==2.8.0",
31+
"pylint==3.3.1",
3232
"flake8==3.7.9",
3333
]
3434

@@ -42,7 +42,7 @@
4242
maintainer_email='[email protected]',
4343
test_suite='segment.analytics.test.all',
4444
packages=['segment.analytics', 'segment.analytics.test'],
45-
python_requires='>=3.6.0',
45+
python_requires='>=3.9.0',
4646
license='MIT License',
4747
install_requires=install_requires,
4848
extras_require={
@@ -56,9 +56,6 @@
5656
"License :: OSI Approved :: MIT License",
5757
"Operating System :: OS Independent",
5858
"Programming Language :: Python",
59-
"Programming Language :: Python :: 3.6",
60-
"Programming Language :: Python :: 3.7",
61-
"Programming Language :: Python :: 3.8",
6259
"Programming Language :: Python :: 3.9",
6360
"Programming Language :: Python :: 3.10",
6461
"Programming Language :: Python :: 3.11",

0 commit comments

Comments
 (0)