fix: Data leak in ThreadingIntegration between threads#4281
fix: Data leak in ThreadingIntegration between threads#4281antonpirker merged 36 commits intomasterfrom
Conversation
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
szokeasaurusrex
left a comment
There was a problem hiding this comment.
lgtm, but check with @sl0thentr0py first (I was unclear about the outcome from the slack thread discussion)
sentrivana
left a comment
There was a problem hiding this comment.
Nice! Please check comments
| and django_version >= (3, 0) | ||
| and django_version < (4, 0) | ||
| ): | ||
| warnings.warn( |
There was a problem hiding this comment.
Since this is happening in Thread.start, we might log this even if a thread is started outside of Django -- but I don't think we have a way of detecting that. And since this is warnings.warn message, it should only be printed once and not spam on every Thread.start, so hopefully this is fine.
There was a problem hiding this comment.
the problem with the unawaited future is only happening if old python, django and channels are used in combination. on a vanilla python project on old python versions the threading works fine.
There was a problem hiding this comment.
Yeah, my point was more that someone might have Django/channels installed in their venv but uses threads in an unrelated script that has nothing to do with their Django app and they would get this warning too. But as said, I don't see a way around this
There was a problem hiding this comment.
now I get it. yes that is true. but as you said, the warning is only emitted once, so I think it is ok.
…ntry-python into antonpirker/threading-tests
It is possible to leak data from started threads into the main thread via the scopes. (Because the same scope object from the main thread could be changed in the started thread.)
This change always makes a fork (copy) of the scopes of the main thread before it propagates those scopes into the started thread.