Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
Expand All @@ -37,7 +36,6 @@ jobs:
fail-fast: false
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "sergeant"
version = "0.26.1"
version = "0.27.0"
readme = "README.md"
homepage = "https://github.com/Intsights/sergeant"
repository = "https://github.com/Intsights/sergeant"
Expand Down
6 changes: 3 additions & 3 deletions sergeant/encoder/serializer/msgpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def encode_extensions(
self,
obj: typing.Any,
) -> typing.Any:
if type(obj) == datetime.datetime:
if type(obj) is datetime.datetime:
return {
'__datetime__': obj.timestamp(),
}
elif type(obj) == tuple:
elif type(obj) is tuple:
return {
'__tuple__': list(obj),
}
elif type(obj) == objects.Task:
elif type(obj) is objects.Task:
return {
'__task__': obj.__dict__,
}
Expand Down
2 changes: 1 addition & 1 deletion sergeant/logging/logstash.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def encode_message(
if attribute_name not in self.logrecord_internal_attributes:
if dataclasses.is_dataclass(attribute_value):
attribute_value = dataclasses.asdict(
attribute_value,
attribute_value, # type: ignore[arg-type] # noqa: I005
)

message['extra'][attribute_name] = attribute_value
Expand Down
2 changes: 1 addition & 1 deletion sergeant/slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def kill_running_background_threads() -> bool:
if thread is threading.main_thread():
continue

if thread.ident:
if thread.ident and not isinstance(thread, threading._DummyThread):
ctypes.pythonapi.PyThreadState_SetAsyncExc(
ctypes.c_ulong(thread.ident),
ctypes.py_object(SystemExit),
Expand Down
22 changes: 19 additions & 3 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,29 @@ services:
- 6380:6379
mongo-node-one:
image: mongo
restart: always
ports:
- 27017:27017
command: >
mongod --port 27017 --replSet test_replica_set --bind_ip_all
mongod --replSet test_replica_set --bind_ip_all
container_name: mongo-one
volumes:
- mongo1_data:/data/db

mongo-node-two:
image: mongo
restart: always
ports:
- 27018:27018
- 27018:27017
command: >
mongod --port 27018 --replSet test_replica_set --bind_ip_all
mongod --replSet test_replica_set --bind_ip_all
container_name: mongo-two
volumes:
- mongo2_data:/data/db


volumes:
mongo1_data:
driver: local
mongo2_data:
driver: local
32 changes: 32 additions & 0 deletions tests/supervisor/test_slave_dummy_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import ctypes
import pytest
import threading

import sergeant.slave


@pytest.fixture
def background_threads():
threads = [threading.Thread(target=threading._DummyThread, daemon=False) for _ in range(3)]

for thread in threads:
thread.start()

yield threads

for thread in threads:
if thread.is_alive():
ctypes.pythonapi.PyThreadState_SetAsyncExc(
ctypes.c_ulong(thread.ident),
ctypes.py_object(SystemExit),
)
thread.join()


def test_kill_running_background_threads(
background_threads,
):
assert sergeant.slave.kill_running_background_threads() is True

for thread in background_threads:
assert not thread.is_alive()