File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1208,3 +1208,33 @@ def test_function(**kwargs: Any) -> None:
12081208
12091209    # SyncToAsync.__call__.loop.run_in_executor has a param named `task_context`. 
12101210    await  test_function (task_context = 1 )
1211+ 
1212+ 
1213+ def  test_nested_task () ->  None :
1214+     async  def  inner () ->  asyncio .Task [None ]:
1215+         return  asyncio .create_task (sync_to_async (print )("inner" ))
1216+ 
1217+     async  def  main () ->  None :
1218+         task  =  await  sync_to_async (async_to_sync (inner ))()
1219+         await  task 
1220+ 
1221+     async_to_sync (main )()
1222+ 
1223+ 
1224+ def  test_nested_task_later () ->  None :
1225+     def  later (fut : asyncio .Future [asyncio .Task [None ]]) ->  None :
1226+         task  =  asyncio .create_task (sync_to_async (print )("later" ))
1227+         fut .set_result (task )
1228+ 
1229+     async  def  inner () ->  asyncio .Future [asyncio .Task [None ]]:
1230+         loop  =  asyncio .get_running_loop ()
1231+         fut  =  loop .create_future ()
1232+         loop .call_later (0.1 , later , fut )
1233+         return  fut 
1234+ 
1235+     async  def  main () ->  None :
1236+         fut  =  await  sync_to_async (async_to_sync (inner ))()
1237+         task  =  await  fut 
1238+         await  task 
1239+ 
1240+     async_to_sync (main )()
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments