Replaced try/except block in recv_task() by match msg, and added new changes to description comment
							parent
							
								
									db0b59abaa
								
							
						
					
					
						commit
						3f5dec82ed
					
				| 
						 | 
					@ -221,9 +221,13 @@ async def open_jsonrpc_session(
 | 
				
			||||||
            '''
 | 
					            '''
 | 
				
			||||||
            receives every ws message and stores it in its corresponding result
 | 
					            receives every ws message and stores it in its corresponding result
 | 
				
			||||||
            field, then sets the event to wakeup original sender tasks.
 | 
					            field, then sets the event to wakeup original sender tasks.
 | 
				
			||||||
 | 
					            also, recieves responses to requests originated from the server side.
 | 
				
			||||||
            '''
 | 
					            '''
 | 
				
			||||||
            async for msg in ws:
 | 
					            async for msg in ws:
 | 
				
			||||||
                try:
 | 
					                match msg:
 | 
				
			||||||
 | 
					                    case {
 | 
				
			||||||
 | 
					                        'result': _
 | 
				
			||||||
 | 
					                    }:
 | 
				
			||||||
                        msg = response_type(**msg)
 | 
					                        msg = response_type(**msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if msg.id not in rpc_results:
 | 
					                        if msg.id not in rpc_results:
 | 
				
			||||||
| 
						 | 
					@ -237,14 +241,15 @@ async def open_jsonrpc_session(
 | 
				
			||||||
                        res['result'] = msg
 | 
					                        res['result'] = msg
 | 
				
			||||||
                        res['event'].set()
 | 
					                        res['event'].set()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                except TypeError:
 | 
					                    case {
 | 
				
			||||||
                    if request_type == None:
 | 
					                        'method': _,
 | 
				
			||||||
                        raise
 | 
					                        'params': _
 | 
				
			||||||
 | 
					                    }:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if request_hook:
 | 
				
			||||||
                            await request_hook(request_type(**msg))
 | 
					                            await request_hook(request_type(**msg))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        n.start_soon(recv_task)
 | 
					        n.start_soon(recv_task)
 | 
				
			||||||
        yield json_rpc
 | 
					        yield json_rpc
 | 
				
			||||||
        n.cancel_scope.cancel()
 | 
					        n.cancel_scope.cancel()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue