Skip to content

Commit 60119c1

Browse files
committed
Added test trying to track down weird segmentation violation from projections with Python 3.13 and MsgStruct instances.
1 parent 45eb039 commit 60119c1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/dcb_tests/test_msgpack.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from copy import deepcopy
2+
from threading import Thread
3+
from unittest import TestCase
4+
5+
from eventsourcing.dcb.msgpack import Decision
6+
7+
8+
class MyDecision(Decision):
9+
a: str
10+
11+
12+
class Test(TestCase):
13+
def test(self) -> None:
14+
# Trying to isolate segmentation violation in Python3.13 with
15+
# projection using DCB application with ImMemoryDCBRecorder and
16+
# eventsourcing.dcb.msgpack.Decision. One suspect is deepcopy of
17+
# msgspec.Struct subclasses, perhaps when crossing threads. This
18+
# test tries to replicate what InMemoryDCBRecorder does with a
19+
# subscription (deepcopy on a different thread). However, no segv.
20+
m = MyDecision(a="a")
21+
self.assertEqual(deepcopy(m), m)
22+
23+
def f() -> None:
24+
self.assertEqual(deepcopy(m), m)
25+
26+
t = Thread(target=f)
27+
t.start()
28+
t.join()

0 commit comments

Comments
 (0)