MCPcopy Index your code
hub / github.com/permitio/opal / create_task

Method create_task

packages/opal-common/opal_common/utils.py:253–268  ·  view source on GitHub ↗

Creates a task on the thread's asyncio loop *without* waiting for it to finish. This is intended to be called from the parent thread as a set-and-forget. the scheduled coroutine is put on the thread's queue and is consumed by one of the thread workers.

(self, coro: Coroutine)

Source from the content-addressed store, hash-verified

251 self.loop.stop()
252
253 def create_task(self, coro: Coroutine):
254 """Creates a task on the thread's asyncio loop *without* waiting for it
255 to finish. This is intended to be called from the parent thread as a
256 set-and-forget.
257
258 the scheduled coroutine is put on the thread's queue and is
259 consumed by one of the thread workers.
260 """
261
262 async def _schedule_task():
263 """Since the queue is infinite, queue.put() will not block."""
264 await self._queue.put(coro)
265
266 # the asyncio loop might not be running yet (if the thread was
267 # not yet started), therefore we do not block on the result.
268 return asyncio.run_coroutine_threadsafe(_schedule_task(), loop=self.loop)
269
270 def run_coro(self, coro: Coroutine):
271 """Can be called from the main thread, but will run the coroutine on

Callers 15

runMethod · 0.80
startup_eventMethod · 0.80
_on_webhookMethod · 0.80
startMethod · 0.80
startMethod · 0.80
startMethod · 0.80
startup_eventMethod · 0.80
_start_updatersMethod · 0.80
_stop_updatersMethod · 0.80

Calls

no outgoing calls

Tested by 1