@contextmanager
def _push_kernel_context(mod):
 global _kernel_context
 assert (_kernel_context is None), 'conrrent simulated kernel not supported'
 _kernel_context = mod
 try:
  (yield)
 finally:
  _kernel_context = None

@ contextmanager def _push_kernel_context ( mod ) : global _kernel_context assert ( _kernel_context is None ) , 'conrrent simulated kernel not supported' _kernel_context = mod try : ( yield ) finally : _kernel_context = None
push the current kernel context .