def fire_coroutine_threadsafe(coro, loop):
 ident = loop.__dict__.get('_thread_ident')
 if ((ident is not None) and (ident == threading.get_ident())):
  raise RuntimeError('Cannot be called from within the event loop')
 if (not coroutines.iscoroutine(coro)):
  raise TypeError(('A coroutine object is required: %s' % coro))
 def callback():
  'Callback to fire coroutine.'
  ensure_future(coro, loop=loop)
 loop.call_soon_threadsafe(callback)
 return

def fire_coroutine_threadsafe ( coro , loop ) : ident = loop . __dict__ . get ( '_thread_ident' ) if ( ( ident is not None ) and ( ident == threading . get_ident ( ) ) ) : raise RuntimeError ( 'Cannot be called from within the event loop' ) if ( not coroutines . iscoroutine ( coro ) ) : raise TypeError ( ( 'A coroutine object is required: %s' % coro ) ) def callback ( ) : ensure_future ( coro , loop = loop ) loop . call_soon_threadsafe ( callback ) return
submit a coroutine object to a given event loop .