Open
Description
This is probably true for the other decorators as well. Same issue if you call the decorators directly.
threading.get_ident() is the same as the async code when the function uses yield. If you change it to return a list it has a different ID.
Heres the code
@sync_to_async
def function_foo(self):
print(threading.get_ident(), 'function')
return 4
@sync_to_async
def generator_foo(self):
print(threading.get_ident(), 'generator')
yield 4
async def receive_json(self, content):
print(threading.get_ident(), 'loop')
print(await self.function_foo())
for i in await self.generator_foo():
print(i)
Heres the output
139945948370688 loop
139945849284352 function
4
139945948370688 generator
4