Changes between Initial Version and Version 1 of Ticket #31920, comment 5


Ignore:
Timestamp:
Aug 24, 2020, 2:25:54 AM (4 years ago)
Author:
Michael Galler

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31920, comment 5

    initial v1  
    55Wouldn't it make sense to have a decorator that automatically executes the function synchronously thread sensitive when it is executed in a async context?
    66
    7 What i came up with after some time is the following:
     7What i came up with after some time is the following based on async_unsafe:
    88
    99{{{
     
    3030
    3131    # If the message is actually a function, then be a no-arguments decorator.
     32
    3233    if callable(message):
    3334        func = message
    34         message = 'You cannot call this from an async context - use a thread or sync_to_async.'
     35        message = ''
    3536        return decorator(func)
    3637    else:
Back to Top