﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34359	Add setting to disable global thread_sensitive flag for Async ORM and Async cache	Jameel A.	nobody	"Apologies if this has been discussed before, but I couldn't find a related issue.

The way the Async ORM interface is currently implemented is by simply introducing new `a`-prefixed methods that wrap the original `QuerySet` methods in `sync_to_async`. On the surface this is a simple, slightly suboptimal, way of implementing `asyncio` support.

Under the surface, though, there be dragons. With `asgiref` enabling the `thread_sensitive` by default, what actually happens is ''ALL'' uses of `sync_to_async` get queued onto a single thread. This can have disastrous performance implications as we've seen in production (especially when used with native `async` code).

While `thread_sensitive` is ''safer'' as mentioned in the docs, it's not always necessary. For example, when using Postgres, the `psycopg` database driver is thread-safe and appears to work fine with the `thread_sensitive` flag disabled.

The issue here is not whether `thread_sensitive` should be `True` by default, but rather there should be a way to disable it when the user ''knows'' it's safe to do so. In particular, for the async ORM and async cache interfaces, it would be wonderful to configure thread sensitivity via a setting."	New feature	closed	Database layer (models, ORM)	4.1	Normal	wontfix			Unreviewed	0	0	0	0	0	0
