e-valuation / EvaP

a university course evaluation system written in Python using Django
Other
95 stars 146 forks source link

Assertion failure due to weak signal receivers having no guarantee of being garbage collected in time #2189

Open richardebeling opened 2 months ago

richardebeling commented 2 months ago

See discussion in https://github.com/e-valuation/EvaP/issues/1361.

Our two weak notification receivers (grep weak=True) were intended to only be active while the current request is being handled. However, we can not assume this, as garbage collection is not guaranteed. We've had at least two sporadic test failures in the last weeks due to this. To replicate, run the tests with a patched manage.py where you added

import gc
gc.disable()

to the top and run the tests with --shuffle=3290553936 (any shuffle where the user_edit view is accessed at least once before the evaluation_edit view test that removes participants and triggers reward point granting.

I don't know yet how to properly implement the behavior we intended to have. If may suffice to unregister the signal receiver at the end of the view.

Edit: While we're at it, I think the grant_reward_points_after_delete function could use a assert not grantings in the if reverse in the if granting case -- we only expect grantings to be set once, otherwise, overwriting of the old value of grantings would be unexpected.

Kakadus commented 3 weeks ago

same thing with seed 1116753744 at test_remove_participants_proportional_reward_points here

Kakadus commented 1 week ago

we discarded the approach in #2229 because it seemed implementation specific. Instead, we want a contextmanager which disconnects the signal directly.