Skip to content

Commit ea6101d

Browse files
authored
Python 3.10 and 3.11, fix (#13)
* Use current_thread() * Add python 3.10 and 3.11 to CI * Check key existence, add python 3.10 and 3.11 to tox * Remove python without support from CI * Use nose-py3 and unittest, drop python 2.7 tests
1 parent 09e387e commit ea6101d

File tree

11 files changed

+20
-25
lines changed

11 files changed

+20
-25
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ on:
66

77
jobs:
88
build:
9-
# As long as we need Python 2.7 here in the test, we can only use up to Ubuntu 20.
10-
# https://github.com/rwth-i6/returnn/issues/1226
11-
# 20.04 is a LTS with 2030 support EOL
12-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-22.04
1310
strategy:
1411
matrix:
15-
python-version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
12+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
1613

1714
steps:
1815
- uses: actions/checkout@v1

logtail/flusher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class FlushWorker(threading.Thread):
1313
def __init__(self, upload, pipe, buffer_capacity, flush_interval):
1414
threading.Thread.__init__(self)
15-
self.parent_thread = threading.currentThread()
15+
self.parent_thread = threading.current_thread()
1616
self.upload = upload
1717
self.pipe = pipe
1818
self.buffer_capacity = buffer_capacity

logtail/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def create_frame(record, message, context, include_extra_attributes=False):
99
r = record.__dict__
1010
# Django sends a request object in the record, which is not JSON serializable
11-
if not isinstance(r["request"], (dict, list, bool, int, float, str)) :
11+
if "request" in r and not isinstance(r["request"], (dict, list, bool, int, float, str)) :
1212
del r["request"]
1313
frame = {}
1414
# Python 3 only solution if we ever drop Python 2.7

test-requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
coverage>=3.7.1
22
httpretty>=0.9.4
3-
nose>=1.3.7
4-
unittest2>=0.8.0
3+
nose-py3
54
mock>=1.0.1

tests/test_flusher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import mock
44
import time
55
import threading
6-
import unittest2
6+
import unittest
77

88
from logtail.compat import queue
99
from logtail.flusher import RETRY_SCHEDULE
1010
from logtail.flusher import FlushWorker
1111
from logtail.uploader import Uploader
1212

1313

14-
class TestFlushWorker(unittest2.TestCase):
14+
class TestFlushWorker(unittest.TestCase):
1515
host = 'https://in.logtail.com'
1616
source_token = 'dummy_source_token'
1717
buffer_capacity = 5

tests/test_formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import time
55
import threading
66
import json
7-
import unittest2
7+
import unittest
88
import pdb
99
import logging
1010

@@ -13,7 +13,7 @@
1313
from logtail.helpers import LogtailContext
1414

1515

16-
class TestLogtailFormatter(unittest2.TestCase):
16+
class TestLogtailFormatter(unittest.TestCase):
1717
def setUp(self):
1818
self.context = LogtailContext()
1919
self.customer = {'id': '1'}

tests/test_frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from logtail.helpers import LogtailContext
66
from sys import version_info
77
import datetime
8-
import unittest2
8+
import unittest
99
import logging
1010

11-
class TestLogtailLogEntry(unittest2.TestCase):
11+
class TestLogtailLogEntry(unittest.TestCase):
1212
def test_create_frame_happy_path(self):
1313
handler = LogtailHandler(source_token="some-source-token")
1414
log_record = logging.LogRecord("logtail-test", 20, "/some/path", 10, "Some log message", [], None)

tests/test_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import mock
44
import time
55
import threading
6-
import unittest2
6+
import unittest
77
import logging
88

99
from logtail.handler import LogtailHandler
1010

1111

12-
class TestLogtailHandler(unittest2.TestCase):
12+
class TestLogtailHandler(unittest.TestCase):
1313
source_token = 'dummy_source_token'
1414
host = 'dummy_host'
1515

tests/test_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# coding: utf-8
22
from __future__ import print_function, unicode_literals
3-
import unittest2
3+
import unittest
44

55
from logtail import LogtailContext
66

77

8-
class TestLogtailContext(unittest2.TestCase):
8+
class TestLogtailContext(unittest.TestCase):
99

1010
def test_exists(self):
1111
c = LogtailContext()

tests/test_uploader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
from __future__ import print_function, unicode_literals
33
import msgpack
44
import mock
5-
import unittest2
5+
import unittest
66

77
from logtail.uploader import Uploader
88

99

10-
class TestUploader(unittest2.TestCase):
10+
class TestUploader(unittest.TestCase):
1111
host = 'https://in.logtail.com'
1212
source_token = 'dummy_source_token'
1313
frame = [1, 2, 3]

0 commit comments

Comments
 (0)