forked from goodboy/tractor
				
			Don't catch key errors from the yielded to scope
							parent
							
								
									b210278e2f
								
							
						
					
					
						commit
						3826bc9972
					
				| 
						 | 
				
			
			@ -161,19 +161,15 @@ async def maybe_open_context(
 | 
			
		|||
    a _Cache hit.
 | 
			
		||||
 | 
			
		||||
    '''
 | 
			
		||||
    # lock resource acquisition around task racing  / ``trio``'s
 | 
			
		||||
    # scheduler protocol
 | 
			
		||||
    await _Cache.lock.acquire()
 | 
			
		||||
 | 
			
		||||
    ctx_key = id(mngr)
 | 
			
		||||
 | 
			
		||||
    value = None
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        # lock feed acquisition around task racing  / ``trio``'s
 | 
			
		||||
        # scheduler protocol
 | 
			
		||||
        value = _Cache.values[key]
 | 
			
		||||
        log.info(f'Reusing _Cached resource for {key}')
 | 
			
		||||
        _Cache.users += 1
 | 
			
		||||
        _Cache.lock.release()
 | 
			
		||||
        yield True, value
 | 
			
		||||
 | 
			
		||||
    except KeyError:
 | 
			
		||||
        log.info(f'Allocating new resource for {key}')
 | 
			
		||||
| 
						 | 
				
			
			@ -196,6 +192,12 @@ async def maybe_open_context(
 | 
			
		|||
 | 
			
		||||
        yield False, value
 | 
			
		||||
 | 
			
		||||
    else:
 | 
			
		||||
        log.info(f'Reusing _Cached resource for {key}')
 | 
			
		||||
        _Cache.users += 1
 | 
			
		||||
        _Cache.lock.release()
 | 
			
		||||
        yield True, value
 | 
			
		||||
 | 
			
		||||
    finally:
 | 
			
		||||
        _Cache.users -= 1
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue