Changes between Initial Version and Version 1 of Ticket #31920, comment 5
- Timestamp:
- Aug 24, 2020, 2:25:54 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31920, comment 5
initial v1 5 5 Wouldn't it make sense to have a decorator that automatically executes the function synchronously thread sensitive when it is executed in a async context? 6 6 7 What i came up with after some time is the following :7 What i came up with after some time is the following based on async_unsafe: 8 8 9 9 {{{ … … 30 30 31 31 # If the message is actually a function, then be a no-arguments decorator. 32 32 33 if callable(message): 33 34 func = message 34 message = ' You cannot call this from an async context - use a thread or sync_to_async.'35 message = '' 35 36 return decorator(func) 36 37 else: